aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/ui')
-rw-r--r--test/functional/ui/decorations_spec.lua15
-rw-r--r--test/functional/ui/float_spec.lua177
-rw-r--r--test/functional/ui/highlight_spec.lua43
-rw-r--r--test/functional/ui/inccommand_spec.lua4
-rw-r--r--test/functional/ui/messages_spec.lua54
-rw-r--r--test/functional/ui/statuscolumn_spec.lua13
-rw-r--r--test/functional/ui/statusline_spec.lua20
7 files changed, 314 insertions, 12 deletions
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index e57e719192..98d221be7d 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -2301,8 +2301,21 @@ describe('extmark decorations', function()
]]}
end)
+ it('virtual text does not crash with blend, conceal and wrap #27836', function()
+ screen:try_resize(50, 3)
+ insert(('a'):rep(45) .. '|hidden|' .. ('b'):rep(45))
+ command('syntax match test /|hidden|/ conceal')
+ command('set conceallevel=2 concealcursor=n')
+ api.nvim_buf_set_extmark(0, ns, 0, 0, {virt_text = {{'FOO'}}, virt_text_pos='right_align', hl_mode='blend'})
+ screen:expect{grid=[[
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa FOO|
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb^b |
+ |
+ ]]}
+ end)
+
it('works with both hl_group and sign_hl_group', function()
- screen:try_resize(screen._width, 3)
+ screen:try_resize(50, 3)
insert('abcdefghijklmn')
api.nvim_buf_set_extmark(0, ns, 0, 0, {sign_text='S', sign_hl_group='NonText', hl_group='Error', end_col=14})
screen:expect{grid=[[
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 4d06a24d3f..361ea3e778 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -550,6 +550,43 @@ describe('float window', function()
eq({ w0 }, api.nvim_list_wins())
end)
+ it('win_splitmove() can move float into a split', function()
+ command('split')
+ eq({'col', {{'leaf', 1001}, {'leaf', 1000}}}, fn.winlayout())
+
+ local win1 = api.nvim_open_win(0, true, {relative = 'editor', row = 1, col = 1, width = 5, height = 5})
+ fn.win_splitmove(win1, 1001, {vertical = true})
+ eq({'col', {{'row', {{'leaf', win1}, {'leaf', 1001}}}, {'leaf', 1000}}}, fn.winlayout())
+ eq('', api.nvim_win_get_config(win1).relative)
+
+ -- Should be unable to create a split relative to a float, though.
+ local win2 = api.nvim_open_win(0, true, {relative = 'editor', row = 1, col = 1, width = 5, height = 5})
+ eq('Vim:E957: Invalid window number', pcall_err(fn.win_splitmove, win1, win2, {vertical = true}))
+ end)
+
+ it('tp_curwin updated if external window is moved into split', function()
+ local screen = Screen.new(20, 7)
+ screen:attach { ext_multigrid = true }
+
+ command('tabnew')
+ local external_win = api.nvim_open_win(0, true, {external = true, width = 5, height = 5})
+ eq(external_win, api.nvim_get_current_win())
+ eq(2, fn.tabpagenr())
+ command('tabfirst')
+ api.nvim_set_current_win(external_win)
+ eq(external_win, api.nvim_get_current_win())
+ eq(1, fn.tabpagenr())
+
+ command('wincmd J')
+ eq(external_win, api.nvim_get_current_win())
+ eq(false, api.nvim_win_get_config(external_win).external)
+ command('tabnext')
+ eq(2, fn.tabpagenr())
+ neq(external_win, api.nvim_get_current_win())
+
+ screen:detach()
+ end)
+
describe('with only one tabpage,', function()
local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}
local old_buf, old_win
@@ -836,6 +873,57 @@ describe('float window', function()
end)
end)
+ describe(':close on non-float with floating windows', function()
+ -- XXX: it isn't really clear whether this should quit Nvim, as if the autocommand
+ -- here is BufUnload then it does quit Nvim.
+ -- But with BufWinLeave, this doesn't quit Nvim if there are no floating windows,
+ -- so it shouldn't quit Nvim if there are floating windows.
+ it('does not quit Nvim if BufWinLeave makes it the only non-float', function()
+ exec([[
+ let g:buf = bufnr()
+ new
+ let s:midwin = win_getid()
+ new
+ setlocal bufhidden=wipe
+ call nvim_win_set_config(s:midwin,
+ \ #{relative: 'editor', row: 5, col: 5, width: 5, height: 5})
+ autocmd BufWinLeave * ++once exe g:buf .. 'bwipe!'
+ ]])
+ eq('Vim(close):E855: Autocommands caused command to abort', pcall_err(command, 'close'))
+ assert_alive()
+ end)
+
+ pending('does not crash if BufUnload makes it the only non-float in tabpage', function()
+ exec([[
+ tabnew
+ let g:buf = bufnr()
+ new
+ let s:midwin = win_getid()
+ new
+ setlocal bufhidden=wipe
+ call nvim_win_set_config(s:midwin,
+ \ #{relative: 'editor', row: 5, col: 5, width: 5, height: 5})
+ autocmd BufUnload * ++once exe g:buf .. 'bwipe!'
+ ]])
+ command('close')
+ assert_alive()
+ end)
+
+ it('does not crash if WinClosed from floating window closes it', function()
+ exec([[
+ tabnew
+ new
+ let s:win = win_getid()
+ call nvim_win_set_config(s:win,
+ \ #{relative: 'editor', row: 5, col: 5, width: 5, height: 5})
+ wincmd t
+ exe $"autocmd WinClosed {s:win} 1close"
+ ]])
+ command('close')
+ assert_alive()
+ end)
+ end)
+
local function with_ext_multigrid(multigrid)
local screen, attrs
before_each(function()
@@ -6169,7 +6257,7 @@ describe('float window', function()
run(on_request, nil, on_setup)
os.remove('Xtest_written')
os.remove('Xtest_written2')
- eq(exited, true)
+ eq(true, exited)
end)
it(':quit two floats in a row', function()
@@ -9030,6 +9118,93 @@ describe('float window', function()
]])
end
end)
+
+ it('correctly placed in or above message area', function()
+ local float_opts = {relative='editor', width=5, height=1, row=100, col=1, border = 'single'}
+ api.nvim_set_option_value('cmdheight', 3, {})
+ command("echo 'cmdline'")
+ local win = api.nvim_open_win(api.nvim_create_buf(false, false), true, float_opts)
+ -- Not hidden behind message area but placed above it.
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|*4
+ [3:----------------------------------------]|*3
+ ## grid 2
+ |
+ {0:~ }|*3
+ ## grid 3
+ cmdline |
+ |*2
+ ## grid 4
+ {5:┌─────┐}|
+ {5:│}{1:^ }{5:│}|
+ {5:└─────┘}|
+ ]], float_pos={
+ [4] = {1001, "NW", 1, 100, 1, true, 50};
+ }, win_viewport={
+ [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [4] = {win = 1001, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ }}
+ else
+ screen:expect{grid=[[
+ |
+ {0:~}{5:┌─────┐}{0: }|
+ {0:~}{5:│}{1:^ }{5:│}{0: }|
+ {0:~}{5:└─────┘}{0: }|
+ cmdline |
+ |*2
+ ]]}
+ end
+ -- Not placed above message area and visible on top of it.
+ api.nvim_win_set_config(win, {zindex = 300})
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|*4
+ [3:----------------------------------------]|*3
+ ## grid 2
+ |
+ {0:~ }|*3
+ ## grid 3
+ cmdline |
+ |*2
+ ## grid 4
+ {5:┌─────┐}|
+ {5:│}{1:^ }{5:│}|
+ {5:└─────┘}|
+ ]], float_pos={
+ [4] = {1001, "NW", 1, 100, 1, true, 300};
+ }, win_viewport={
+ [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [4] = {win = 1001, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ }}
+ else
+ screen:expect{grid=[[
+ |
+ {0:~ }|*3
+ c{5:┌─────┐} |
+ {5:│}{1:^ }{5:│} |
+ {5:└─────┘} |
+ ]]}
+ end
+ end)
+
+ it('attempt to turn into split with no room', function()
+ eq('Vim(split):E36: Not enough room', pcall_err(command, 'execute "split |"->repeat(&lines)'))
+ command('vsplit | wincmd | | wincmd p')
+ api.nvim_open_win(0, true, {relative = "editor", row = 0, col = 0, width = 5, height = 5})
+ local config = api.nvim_win_get_config(0)
+ eq('editor', config.relative)
+
+ local layout = fn.winlayout()
+ local restcmd = fn.winrestcmd()
+ eq('Vim(wincmd):E36: Not enough room', pcall_err(command, 'wincmd K'))
+ eq('Vim(wincmd):E36: Not enough room', pcall_err(command, 'wincmd J'))
+ eq(layout, fn.winlayout())
+ eq(restcmd, fn.winrestcmd())
+ eq(config, api.nvim_win_get_config(0))
+ end)
end
describe('with ext_multigrid', function()
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index 727dc38829..f6d262c6fd 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -1380,6 +1380,8 @@ describe('CursorColumn highlight', function()
[1] = { background = Screen.colors.Gray90 }, -- CursorColumn
[2] = { bold = true, foreground = Screen.colors.Blue1 }, -- NonText
[3] = { bold = true }, -- ModeMsg
+ [4] = { background = Screen.colors.Red },
+ [5] = { background = Screen.colors.Blue },
})
screen:attach()
end)
@@ -1454,6 +1456,47 @@ describe('CursorColumn highlight', function()
]],
})
end)
+
+ it('is not shown on current line with virtualedit', function()
+ exec([[
+ hi! CursorColumn guibg=Red
+ hi! CursorLine guibg=Blue
+ set virtualedit=all cursorline cursorcolumn
+ ]])
+ insert('line 1\nline 2\nline 3')
+ feed('k')
+ screen:expect([[
+ line {4:1} |
+ {5:line ^2 }|
+ line {4:3} |
+ {2:~ }|*4
+ |
+ ]])
+ feed('l')
+ screen:expect([[
+ line 1{4: } |
+ {5:line 2^ }|
+ line 3{4: } |
+ {2:~ }|*4
+ |
+ ]])
+ feed('l')
+ screen:expect([[
+ line 1 {4: } |
+ {5:line 2 ^ }|
+ line 3 {4: } |
+ {2:~ }|*4
+ |
+ ]])
+ feed('l')
+ screen:expect([[
+ line 1 {4: } |
+ {5:line 2 ^ }|
+ line 3 {4: } |
+ {2:~ }|*4
+ |
+ ]])
+ end)
end)
describe('ColorColumn highlight', function()
diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua
index 29c8c43ca1..d143c594f5 100644
--- a/test/functional/ui/inccommand_spec.lua
+++ b/test/functional/ui/inccommand_spec.lua
@@ -204,8 +204,8 @@ describe(":substitute, 'inccommand' preserves", function()
feed(':%s/as/glork/')
poke_eventloop()
feed('<enter>')
- eq(api.nvim_get_option_value('undolevels', { scope = 'global' }), 139)
- eq(api.nvim_get_option_value('undolevels', { buf = 0 }), 34)
+ eq(139, api.nvim_get_option_value('undolevels', { scope = 'global' }))
+ eq(34, api.nvim_get_option_value('undolevels', { buf = 0 }))
end)
end
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index 31b1464589..131622bcc5 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -844,7 +844,7 @@ describe('ui/ext_messages', function()
}
end)
- it('implies ext_cmdline and ignores cmdheight', function()
+ it("implies ext_cmdline but allows changing 'cmdheight'", function()
eq(0, eval('&cmdheight'))
feed(':set cmdheight=1')
screen:expect {
@@ -864,15 +864,17 @@ describe('ui/ext_messages', function()
feed('<cr>')
screen:expect([[
^ |
- {1:~ }|*4
+ {1:~ }|*3
+ |
]])
- eq(0, eval('&cmdheight'))
+ eq(1, eval('&cmdheight'))
feed(':set cmdheight=0')
screen:expect {
grid = [[
^ |
- {1:~ }|*4
+ {1:~ }|*3
+ |
]],
cmdline = {
{
@@ -1625,13 +1627,41 @@ describe('ui/ext_messages', function()
{1:~ }|*5
]])
- feed('<c-l>')
- screen:expect([[
+ -- <c-l> (same as :mode) does _not_ clear intro message
+ feed('<c-l>i')
+ screen:expect {
+ grid = [[
^ |
+ {1:~ }|*4
+ {MATCH:.*}|
+ {1:~ }|
+ {1:~ }Nvim is open source and freely distributable{1: }|
+ {1:~ }https://neovim.io/#chat{1: }|
+ {1:~ }|
+ {1:~ }type :help nvim{5:<Enter>} if you are new! {1: }|
+ {1:~ }type :checkhealth{5:<Enter>} to optimize Nvim{1: }|
+ {1:~ }type :q{5:<Enter>} to exit {1: }|
+ {1:~ }type :help{5:<Enter>} for help {1: }|
+ {1:~ }|
+ {1:~{MATCH: +}}type :help news{5:<Enter>} to see changes in v{MATCH:%d+%.%d+}{1:{MATCH: +}}|
+ {1:~ }|
+ {MATCH:.*}|*2
+ {1:~ }|*5
+ ]],
+ showmode = { { '-- INSERT --', 3 } },
+ }
+
+ -- but editing text does..
+ feed('x')
+ screen:expect {
+ grid = [[
+ x^ |
{1:~ }|*23
- ]])
+ ]],
+ showmode = { { '-- INSERT --', 3 } },
+ }
- feed(':intro<cr>')
+ feed('<esc>:intro<cr>')
screen:expect {
grid = [[
^ |
@@ -1655,6 +1685,14 @@ describe('ui/ext_messages', function()
{ content = { { 'Press ENTER or type command to continue', 4 } }, kind = 'return_prompt' },
},
}
+
+ feed('<cr>')
+ screen:expect {
+ grid = [[
+ ^x |
+ {1:~ }|*23
+ ]],
+ }
end)
it('supports global statusline', function()
diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua
index 3a3ff25c39..41406a5860 100644
--- a/test/functional/ui/statuscolumn_spec.lua
+++ b/test/functional/ui/statuscolumn_spec.lua
@@ -927,4 +927,17 @@ describe('statuscolumn', function()
|
]])
end)
+
+ it('line increase properly redraws buffer text with relativenumber #27709', function()
+ screen:try_resize(33, 4)
+ command([[set rnu nuw=3 stc=%l\ ]])
+ command('call setline(1, range(1, 99))')
+ feed('Gyyp')
+ screen:expect([[
+ 98 98 |
+ 99 99 |
+ 100 ^99 |
+ |
+ ]])
+ end)
end)
diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua
index fee4b64d44..000e2b1b04 100644
--- a/test/functional/ui/statusline_spec.lua
+++ b/test/functional/ui/statusline_spec.lua
@@ -11,6 +11,7 @@ local exec = helpers.exec
local exec_lua = helpers.exec_lua
local eval = helpers.eval
local sleep = vim.uv.sleep
+local pcall_err = helpers.pcall_err
local mousemodels = { 'extend', 'popup', 'popup_setpos' }
@@ -474,6 +475,25 @@ describe('global statusline', function()
|
]])
end)
+
+ it('horizontal separators unchanged when failing to split-move window', function()
+ exec([[
+ botright split
+ let &winwidth = &columns
+ let &winminwidth = &columns
+ ]])
+ eq('Vim(wincmd):E36: Not enough room', pcall_err(command, 'wincmd L'))
+ command('mode')
+ screen:expect([[
+ |
+ {1:~ }|*5
+ ────────────────────────────────────────────────────────────|
+ ^ |
+ {1:~ }|*6
+ {2:[No Name] 0,0-1 All}|
+ |
+ ]])
+ end)
end)
it('statusline does not crash if it has Arabic characters #19447', function()