diff options
Diffstat (limited to 'test/functional/ui')
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 86 | ||||
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 45 | ||||
-rw-r--r-- | test/functional/ui/messages_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/ui/mouse_spec.lua | 15 | ||||
-rw-r--r-- | test/functional/ui/multigrid_spec.lua | 11 | ||||
-rw-r--r-- | test/functional/ui/options_spec.lua | 7 | ||||
-rw-r--r-- | test/functional/ui/popupmenu_spec.lua | 127 | ||||
-rw-r--r-- | test/functional/ui/wildmode_spec.lua | 58 | ||||
-rw-r--r-- | test/functional/ui/winbar_spec.lua | 7 |
9 files changed, 345 insertions, 17 deletions
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 789f1c6487..db5a775632 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -31,6 +31,8 @@ describe('decorations providers', function() [12] = {foreground = tonumber('0x990000')}; [13] = {background = Screen.colors.LightBlue}; [14] = {background = Screen.colors.WebGray, foreground = Screen.colors.DarkBlue}; + [15] = {special = Screen.colors.Blue1, undercurl = true}, + [16] = {special = Screen.colors.Red, undercurl = true}, } end) @@ -56,7 +58,7 @@ describe('decorations providers', function() a.nvim_set_decoration_provider(_G.ns1, { on_start = on_do; on_buf = on_do; on_win = on_do; on_line = on_do; - on_end = on_do; + on_end = on_do; _on_spell_nav = on_do; }) return _G.ns1 ]]) @@ -95,7 +97,7 @@ describe('decorations providers', function() | ]]} check_trace { - { "start", 4, 40 }; + { "start", 4 }; { "win", 1000, 1, 0, 8 }; { "line", 1000, 1, 0 }; { "line", 1000, 1, 1 }; @@ -119,7 +121,7 @@ describe('decorations providers', function() | ]]} check_trace { - { "start", 5, 10 }; + { "start", 5 }; { "buf", 1 }; { "win", 1000, 1, 0, 8 }; { "line", 1000, 1, 6 }; @@ -156,6 +158,84 @@ describe('decorations providers', function() ]]} end) + it('can indicate spellchecked points', function() + exec [[ + set spell + set spelloptions=noplainbuffer + syntax off + ]] + + insert [[ + I am well written text. + i am not capitalized. + I am a speling mistakke. + ]] + + setup_provider [[ + local ns = a.nvim_create_namespace "spell" + beamtrace = {} + local function on_do(kind, ...) + if kind == 'win' or kind == 'spell' then + a.nvim_buf_set_extmark(0, ns, 0, 0, { end_row = 2, end_col = 23, spell = true, ephemeral = true }) + end + table.insert(beamtrace, {kind, ...}) + end + ]] + + check_trace { + { "start", 5 }; + { "win", 1000, 1, 0, 5 }; + { "line", 1000, 1, 0 }; + { "line", 1000, 1, 1 }; + { "line", 1000, 1, 2 }; + { "line", 1000, 1, 3 }; + { "end", 5 }; + } + + feed "gg0" + + screen:expect{grid=[[ + ^I am well written text. | + {15:i} am not capitalized. | + I am a {16:speling} {16:mistakke}. | + | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed "]s" + check_trace { + { "spell", 1000, 1, 1, 0, 1, -1 }; + } + screen:expect{grid=[[ + I am well written text. | + {15:^i} am not capitalized. | + I am a {16:speling} {16:mistakke}. | + | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed "]s" + check_trace { + { "spell", 1000, 1, 2, 7, 2, -1 }; + } + screen:expect{grid=[[ + I am well written text. | + {15:i} am not capitalized. | + I am a {16:^speling} {16:mistakke}. | + | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + it('can predefine highlights', function() screen:try_resize(40, 16) insert(mulholland) diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 4e3d62509c..5ffe9ddaad 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -2333,6 +2333,51 @@ describe("'winhighlight' highlight", function() helpers.assert_alive() end) + + it('can redraw statusline on cursor movement', function() + screen:try_resize(40, 8) + exec [[ + set statusline=%f%=%#Background1#%l,%c%V\ %P + split + ]] + insert [[ + some text + more text]] + screen:expect{grid=[[ + some text | + more tex^t | + {0:~ }| + {3:[No Name] }{1:2,9 All}| + some text | + more text | + {4:[No Name] }{1:1,1 All}| + | + ]]} + + command 'set winhl=Background1:Background2' + screen:expect{grid=[[ + some text | + more tex^t | + {0:~ }| + {3:[No Name] }{5:2,9 All}| + some text | + more text | + {4:[No Name] }{1:1,1 All}| + | + ]]} + + feed 'k' + screen:expect{grid=[[ + some tex^t | + more text | + {0:~ }| + {3:[No Name] }{5:1,9 All}| + some text | + more text | + {4:[No Name] }{1:1,1 All}| + | + ]]} + end) end) describe('highlight namespaces', function() diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 2cff7c1cf4..522c9ccba2 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1077,10 +1077,10 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim ]]} end) - it('redraws NOT_VALID correctly after message', function() - -- edge case: only one window was set NOT_VALID. Original report + it('redraws UPD_NOT_VALID correctly after message', function() + -- edge case: only one window was set UPD_NOT_VALID. Original report -- used :make, but fake it using one command to set the current - -- window NOT_VALID and another to show a long message. + -- window UPD_NOT_VALID and another to show a long message. command("set more") feed(':new<cr><c-w><c-w>') screen:expect{grid=[[ diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index 9896b11218..8c5475ecce 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -1585,7 +1585,20 @@ describe('ui/mouse/input', function() eq(0, meths.get_var('mouse_up2')) end) - it('feeding <MouseMove> does not use uninitialized memory #19480', function() + it('<MouseMove> is not translated into multiclicks and can be mapped', function() + meths.set_var('mouse_move', 0) + meths.set_var('mouse_move2', 0) + command('nnoremap <MouseMove> <Cmd>let g:mouse_move += 1<CR>') + command('nnoremap <2-MouseMove> <Cmd>let g:mouse_move2 += 1<CR>') + feed('<MouseMove><0,0>') + feed('<MouseMove><0,0>') + meths.input_mouse('move', '', '', 0, 0, 0) + meths.input_mouse('move', '', '', 0, 0, 0) + eq(4, meths.get_var('mouse_move')) + eq(0, meths.get_var('mouse_move2')) + end) + + it('feeding <MouseMove> in Normal mode does not use uninitialized memory #19480', function() feed('<MouseMove>') helpers.poke_eventloop() helpers.assert_alive() diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index b30aa67fd3..78a1e8c677 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -3,7 +3,9 @@ local Screen = require('test.functional.ui.screen') local clear = helpers.clear local feed, command, insert = helpers.feed, helpers.command, helpers.insert local eq = helpers.eq +local funcs = helpers.funcs local meths = helpers.meths +local curwin = helpers.curwin local poke_eventloop = helpers.poke_eventloop @@ -871,6 +873,15 @@ describe('ext_multigrid', function() before_each(function() screen:try_resize_grid(2, 60, 20) end) + + it('winwidth() winheight() getwininfo() return inner width and height #19743', function() + eq(60, funcs.winwidth(0)) + eq(20, funcs.winheight(0)) + local win_info = funcs.getwininfo(curwin().id)[1] + eq(60, win_info.width) + eq(20, win_info.height) + end) + it('gets written till grid width', function() insert(('a'):rep(60).."\n") diff --git a/test/functional/ui/options_spec.lua b/test/functional/ui/options_spec.lua index 8d7c404637..bd0d2104db 100644 --- a/test/functional/ui/options_spec.lua +++ b/test/functional/ui/options_spec.lua @@ -19,6 +19,7 @@ describe('UI receives option updates', function() linespace=0, pumblend=0, mousefocus=false, + mousemoveevent=false, showtabline=1, termguicolors=false, ttimeout=true, @@ -131,6 +132,12 @@ describe('UI receives option updates', function() eq(expected, screen.options) end) + command("set mousemoveevent") + expected.mousemoveevent = true + screen:expect(function() + eq(expected, screen.options) + end) + command("set nottimeout") expected.ttimeout = false screen:expect(function() diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index e11cd1e859..3c752875f0 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -1990,6 +1990,22 @@ describe('builtin popupmenu', function() efine unplace^ | ]]) + -- Pressing <Left> after that should move the cursor + feed('<Left>') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {4: }| + :sign define jump list place und| + efine unplac^e | + ]]) + feed('<End>') + -- Pressing <C-D> when the popup menu is displayed should remove the popup -- menu feed('<C-U>sign <Tab><C-D>') @@ -2739,7 +2755,7 @@ describe('builtin popupmenu', function() menu PopUp.bar :let g:menustr = 'bar'<CR> menu PopUp.baz :let g:menustr = 'baz'<CR> ]]) - meths.input_mouse('right', 'press', '', 0, 0, 4) + feed('<RightMouse><4,0>') screen:expect([[ ^popup menu test | {1:~ }{n: foo }{1: }| @@ -2776,7 +2792,7 @@ describe('builtin popupmenu', function() :let g:menustr = 'bar' | ]]) eq('bar', meths.get_var('menustr')) - meths.input_mouse('right', 'press', '', 0, 1, 20) + feed('<RightMouse><20,1>') screen:expect([[ ^popup menu test | {1:~ }| @@ -2785,7 +2801,7 @@ describe('builtin popupmenu', function() {1:~ }{n: baz }{1: }| :let g:menustr = 'bar' | ]]) - meths.input_mouse('left', 'press', '', 0, 4, 22) + feed('<LeftMouse><22,4>') screen:expect([[ ^popup menu test | {1:~ }| @@ -2795,7 +2811,7 @@ describe('builtin popupmenu', function() :let g:menustr = 'baz' | ]]) eq('baz', meths.get_var('menustr')) - meths.input_mouse('right', 'press', '', 0, 0, 4) + feed('<RightMouse><4,0>') screen:expect([[ ^popup menu test | {1:~ }{n: foo }{1: }| @@ -2804,7 +2820,7 @@ describe('builtin popupmenu', function() {1:~ }| :let g:menustr = 'baz' | ]]) - meths.input_mouse('right', 'drag', '', 0, 3, 6) + feed('<RightDrag><6,3>') screen:expect([[ ^popup menu test | {1:~ }{n: foo }{1: }| @@ -2813,7 +2829,7 @@ describe('builtin popupmenu', function() {1:~ }| :let g:menustr = 'baz' | ]]) - meths.input_mouse('right', 'release', '', 0, 1, 6) + feed('<RightRelease><6,1>') screen:expect([[ ^popup menu test | {1:~ }| @@ -2823,6 +2839,38 @@ describe('builtin popupmenu', function() :let g:menustr = 'foo' | ]]) eq('foo', meths.get_var('menustr')) + eq(false, screen.options.mousemoveevent) + feed('<RightMouse><4,0>') + screen:expect([[ + ^popup menu test | + {1:~ }{n: foo }{1: }| + {1:~ }{n: bar }{1: }| + {1:~ }{n: baz }{1: }| + {1:~ }| + :let g:menustr = 'foo' | + ]]) + eq(true, screen.options.mousemoveevent) + feed('<MouseMove><6,3>') + screen:expect([[ + ^popup menu test | + {1:~ }{n: foo }{1: }| + {1:~ }{n: bar }{1: }| + {1:~ }{s: baz }{1: }| + {1:~ }| + :let g:menustr = 'foo' | + ]]) + eq(true, screen.options.mousemoveevent) + feed('<LeftMouse><6,2>') + screen:expect([[ + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :let g:menustr = 'bar' | + ]]) + eq(false, screen.options.mousemoveevent) + eq('bar', meths.get_var('menustr')) end) end) @@ -3031,5 +3079,72 @@ describe('builtin popupmenu with ui/ext_multigrid', function() :let g:menustr = 'foo' | ]]}) eq('foo', meths.get_var('menustr')) + eq(false, screen.options.mousemoveevent) + meths.input_mouse('right', 'press', '', 2, 0, 4) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :let g:menustr = 'foo' | + ## grid 4 + {n: foo }| + {n: bar }| + {n: baz }| + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 100}}}) + eq(true, screen.options.mousemoveevent) + meths.input_mouse('move', '', '', 2, 3, 6) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :let g:menustr = 'foo' | + ## grid 4 + {n: foo }| + {n: bar }| + {s: baz }| + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 100}}}) + eq(true, screen.options.mousemoveevent) + meths.input_mouse('left', 'press', '', 2, 2, 6) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :let g:menustr = 'bar' | + ]]}) + eq(false, screen.options.mousemoveevent) + eq('bar', meths.get_var('menustr')) end) end) diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 98398bc7a1..58ffa3bda8 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -461,20 +461,20 @@ end) describe('command line completion', function() local screen before_each(function() + clear() screen = Screen.new(40, 5) screen:set_default_attr_ids({ [1] = {bold = true, foreground = Screen.colors.Blue1}, [2] = {foreground = Screen.colors.Grey0, background = Screen.colors.Yellow}, [3] = {bold = true, reverse = true}, }) + screen:attach() end) after_each(function() os.remove('Xtest-functional-viml-compl-dir') end) it('lists directories with empty PATH', function() - clear() - screen:attach() local tmp = funcs.tempname() command('e '.. tmp) command('cd %:h') @@ -491,8 +491,6 @@ describe('command line completion', function() end) it('completes env var names #9681', function() - clear() - screen:attach() command('let $XTEST_1 = "foo" | let $XTEST_2 = "bar"') command('set wildmenu wildmode=full') feed(':!echo $XTEST_<tab>') @@ -521,6 +519,58 @@ describe('command line completion', function() :!echo $XTEST_1AaあB^ | ]]) end) + + it('does not leak memory with <S-Tab> with wildmenu and only one match #19874', function() + meths.set_option('wildmenu', true) + meths.set_option('wildmode', 'full') + meths.set_option('wildoptions', 'pum') + + feed(':sign unpla<S-Tab>') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + :sign unplace^ | + ]]) + + feed('<Space>buff<Tab>') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + :sign unplace buffer=^ | + ]]) + end) + + it('does not show matches with <S-Tab> without wildmenu with wildmode=full', function() + meths.set_option('wildmenu', false) + meths.set_option('wildmode', 'full') + + feed(':sign <S-Tab>') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + :sign unplace^ | + ]]) + end) + + it('shows matches with <S-Tab> without wildmenu with wildmode=list', function() + meths.set_option('wildmenu', false) + meths.set_option('wildmode', 'list') + + feed(':sign <S-Tab>') + screen:expect([[ + {3: }| + :sign define | + define list undefine | + jump place unplace | + :sign unplace^ | + ]]) + end) end) describe('ui/ext_wildmenu', function() diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua index 8976c4371f..ece27ec3ff 100644 --- a/test/functional/ui/winbar_spec.lua +++ b/test/functional/ui/winbar_spec.lua @@ -7,6 +7,8 @@ local meths = helpers.meths local eq = helpers.eq local poke_eventloop = helpers.poke_eventloop local feed = helpers.feed +local funcs = helpers.funcs +local curwin = helpers.curwin local pcall_err = helpers.pcall_err describe('winbar', function() @@ -48,6 +50,11 @@ describe('winbar', function() {3:~ }| | ]]) + -- winbar is excluded from the heights returned by winheight() and getwininfo() + eq(11, funcs.winheight(0)) + local win_info = funcs.getwininfo(curwin().id)[1] + eq(11, win_info.height) + eq(1, win_info.winbar) end) it('works with custom \'fillchars\' value', function() |