diff options
Diffstat (limited to 'test/functional/ui')
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 43 | ||||
-rw-r--r-- | test/functional/ui/float_spec.lua | 57 | ||||
-rw-r--r-- | test/functional/ui/statusline_spec.lua | 55 |
3 files changed, 131 insertions, 24 deletions
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 524a1351f3..a4c024b526 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -687,7 +687,7 @@ describe('decorations providers', function() ]]} end) - it('can add new providers during redraw #26652', function() + it('can add new providers during redraw #26652', function() setup_provider [[ local ns = api.nvim_create_namespace('test_no_add') function on_do(...) @@ -697,6 +697,47 @@ describe('decorations providers', function() helpers.assert_alive() end) + + it('supports subpriorities (order of definitions in a query file #27131)', function() + insert(mulholland) + setup_provider [[ + local test_ns = api.nvim_create_namespace('mulholland') + function on_do(event, ...) + if event == "line" then + local win, buf, line = ... + api.nvim_buf_set_extmark(buf, test_ns, line, 0, { + end_row = line + 1, + hl_eol = true, + hl_group = 'Comment', + ephemeral = true, + priority = 100, + _subpriority = 20, + }) + + -- This extmark is set last but has a lower subpriority, so the first extmark "wins" + api.nvim_buf_set_extmark(buf, test_ns, line, 0, { + end_row = line + 1, + hl_eol = true, + hl_group = 'String', + ephemeral = true, + priority = 100, + _subpriority = 10, + }) + end + end + ]] + + screen:expect{grid=[[ + {4:// just to see if there was an accident }| + {4:// on Mulholland Drive }| + {4:try_start(); }| + {4:bufref_T save_buf; }| + {4:switch_buffer(&save_buf, buf); }| + {4:posp = getmark(mark, false); }| + {4:restore_buffer(&save_buf);^ }| + | + ]]} + end) end) local example_text = [[ diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index b05e7aceda..397c1f6132 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -104,14 +104,20 @@ describe('float window', function() end) it('open with WinNew autocmd', function() - local res = exec_lua([[ - local triggerd = false + local new_triggered_before_enter, new_curwin, win = unpack(exec_lua([[ + local enter_triggered = false + local new_triggered_before_enter = false + local new_curwin local buf = vim.api.nvim_create_buf(true, true) + vim.api.nvim_create_autocmd('WinEnter', { + callback = function() + enter_triggered = true + end + }) vim.api.nvim_create_autocmd('WinNew', { - callback = function(opt) - if opt.buf == buf then - triggerd = true - end + callback = function() + new_triggered_before_enter = not enter_triggered + new_curwin = vim.api.nvim_get_current_win() end }) local opts = { @@ -120,10 +126,11 @@ describe('float window', function() width = 1, height = 1, noautocmd = false, } - vim.api.nvim_open_win(buf, true, opts) - return triggerd - ]]) - eq(true, res) + local win = vim.api.nvim_open_win(buf, true, opts) + return {new_triggered_before_enter, new_curwin, win} + ]])) + eq(true, new_triggered_before_enter) + eq(win, new_curwin) end) it('opened with correct height', function() @@ -1095,7 +1102,7 @@ describe('float window', function() local expected = {anchor='NW', col=5, external=false, focusable=true, height=2, relative='editor', row=3, width=20, zindex=60, hide=false} eq(expected, api.nvim_win_get_config(win)) - eq({relative='', external=false, focusable=true, hide=false}, api.nvim_win_get_config(0)) + eq({external=false, focusable=true, hide=false, relative='',split="left",width=40,height=6}, api.nvim_win_get_config(0)) if multigrid then api.nvim_win_set_config(win, {external=true, width=10, height=1}) @@ -2878,27 +2885,31 @@ describe('float window', function() it('API has proper error messages', function() local buf = api.nvim_create_buf(false,false) eq("Invalid key: 'bork'", - pcall_err(api.nvim_open_win,buf, false, {width=20,height=2,bork=true})) - eq("'win' key is only valid with relative='win'", - pcall_err(api.nvim_open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,win=0})) + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,bork=true})) + eq("'win' key is only valid with relative='win' and relative=''", + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor',row=0,col=0,win=0})) + eq("floating windows cannot have 'vertical'", + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor',row=0,col=0,vertical=true})) + eq("floating windows cannot have 'split'", + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor',row=0,col=0,split="left"})) eq("Only one of 'relative' and 'external' must be used", - pcall_err(api.nvim_open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,external=true})) + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor',row=0,col=0,external=true})) eq("Invalid value of 'relative' key", - pcall_err(api.nvim_open_win,buf, false, {width=20,height=2,relative='shell',row=0,col=0})) + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='shell',row=0,col=0})) eq("Invalid value of 'anchor' key", - pcall_err(api.nvim_open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,anchor='bottom'})) + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor',row=0,col=0,anchor='bottom'})) eq("'relative' requires 'row'/'col' or 'bufpos'", - pcall_err(api.nvim_open_win,buf, false, {width=20,height=2,relative='editor'})) + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor'})) eq("'width' key must be a positive Integer", - pcall_err(api.nvim_open_win,buf, false, {width=-1,height=2,relative='editor', row=0, col=0})) + pcall_err(api.nvim_open_win, buf, false, {width=-1,height=2,relative='editor', row=0, col=0})) eq("'height' key must be a positive Integer", - pcall_err(api.nvim_open_win,buf, false, {width=20,height=-1,relative='editor', row=0, col=0})) + pcall_err(api.nvim_open_win, buf, false, {width=20,height=-1,relative='editor', row=0, col=0})) eq("'height' key must be a positive Integer", - pcall_err(api.nvim_open_win,buf, false, {width=20,height=0,relative='editor', row=0, col=0})) + pcall_err(api.nvim_open_win, buf, false, {width=20,height=0,relative='editor', row=0, col=0})) eq("Must specify 'width'", - pcall_err(api.nvim_open_win,buf, false, {relative='editor', row=0, col=0})) + pcall_err(api.nvim_open_win, buf, false, {relative='editor', row=0, col=0})) eq("Must specify 'height'", - pcall_err(api.nvim_open_win,buf, false, {relative='editor', row=0, col=0, width=2})) + pcall_err(api.nvim_open_win, buf, false, {relative='editor', row=0, col=0, width=2})) end) it('can be placed relative window or cursor', function() diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 711e056376..fee4b64d44 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -720,3 +720,58 @@ it('uses "stl" and "stlnc" fillchars even if they are the same #19803', function ]], } end) + +it('showcmdloc=statusline works with vertical splits', function() + clear() + local screen = Screen.new(53, 4) + screen:set_default_attr_ids { + [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [2] = { bold = true, reverse = true }, -- StatusLine + [3] = { reverse = true }, -- StatusLineNC + } + screen:attach() + command('rightbelow vsplit') + command('set showcmd showcmdloc=statusline') + feed('1234') + screen:expect([[ + │^ | + {1:~ }│{1:~ }| + {3:[No Name] }{2:[No Name] 1234 }| + | + ]]) + feed('<Esc>') + command('set laststatus=3') + feed('1234') + screen:expect([[ + │^ | + {1:~ }│{1:~ }| + {2:[No Name] 1234 }| + | + ]]) +end) + +it('keymap is shown with vertical splits #27269', function() + clear() + local screen = Screen.new(53, 4) + screen:set_default_attr_ids { + [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [2] = { bold = true, reverse = true }, -- StatusLine + [3] = { reverse = true }, -- StatusLineNC + } + screen:attach() + command('setlocal keymap=dvorak') + command('rightbelow vsplit') + screen:expect([[ + │^ | + {1:~ }│{1:~ }| + {3:[No Name] <en-dv> }{2:[No Name] <en-dv> }| + | + ]]) + command('set laststatus=3') + screen:expect([[ + │^ | + {1:~ }│{1:~ }| + {2:[No Name] <en-dv> }| + | + ]]) +end) |