diff options
Diffstat (limited to 'test/functional/ui/wildmode_spec.lua')
-rw-r--r-- | test/functional/ui/wildmode_spec.lua | 379 |
1 files changed, 172 insertions, 207 deletions
diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 3201135b67..667dd64d62 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -1,8 +1,8 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, feed, command = helpers.clear, helpers.feed, helpers.command -local funcs = helpers.funcs -local meths = helpers.meths +local fn = helpers.fn +local api = helpers.api local eq = helpers.eq local eval = helpers.eval local retry = helpers.retry @@ -20,97 +20,99 @@ describe("'wildmenu'", function() -- oldtest: Test_wildmenu_screendump() it('works', function() screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText - [1] = {foreground = Screen.colors.Black, background = Screen.colors.Yellow}; -- WildMenu - [2] = {bold = true, reverse = true}; -- StatusLine + [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [1] = { foreground = Screen.colors.Black, background = Screen.colors.Yellow }, -- WildMenu + [2] = { bold = true, reverse = true }, -- StatusLine }) -- Test simple wildmenu feed(':sign <Tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {1:define}{2: jump list > }| :sign define^ | - ]]} + ]], + } feed('<Tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:define }{1:jump}{2: list > }| :sign jump^ | - ]]} + ]], + } feed('<Tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:define jump }{1:list}{2: > }| :sign list^ | - ]]} + ]], + } -- Looped back to the original value feed('<Tab><Tab><Tab><Tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:define jump list > }| :sign ^ | - ]]} + ]], + } -- Test that the wild menu is cleared properly feed('<Space>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 :sign ^ | - ]]} + ]], + } -- Test that a different wildchar still works feed('<Esc>') command('set wildchar=<Esc>') feed(':sign <Esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {1:define}{2: jump list > }| :sign define^ | - ]]} + ]], + } -- Double-<Esc> is a hard-coded method to escape while wildchar=<Esc>. Make -- sure clean up is properly done in edge case like this. feed('<Esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | - ]]} + ]], + } end) it('C-E to cancel wildmenu completion restore original input', function() feed(':sign <tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 define jump list > | :sign define^ | ]]) feed('<C-E>') screen:expect([[ | - ~ | - ~ | - ~ | + ~ |*3 :sign ^ | ]]) end) @@ -119,17 +121,14 @@ describe("'wildmenu'", function() feed(':sign <tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 define jump list > | :sign define^ | ]]) feed('<tab><C-Y>') screen:expect([[ | - ~ | - ~ | - ~ | + ~ |*3 :sign jump^ | ]]) end) @@ -139,8 +138,7 @@ describe("'wildmenu'", function() feed(':sign <tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 define jump list > | :sign define^ | ]]) @@ -154,16 +152,14 @@ describe("'wildmenu'", function() feed(':sign <tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 define jump list > | :sign define^ | ]]) feed('<space>') screen:expect([[ | - ~ | - ~ | + ~ |*2 [No Name] | :sign define ^ | ]]) @@ -174,8 +170,7 @@ describe("'wildmenu'", function() feed(':j<Tab><Tab><Tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 join jumps | :j^ | ]]) @@ -183,8 +178,7 @@ describe("'wildmenu'", function() feed('<BS><Tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 ! # & < = > @ > | :!^ | ]]) @@ -194,52 +188,51 @@ describe("'wildmenu'", function() command('set wildmenu wildmode=full') command('set scrollback=4') feed((':terminal "%s" REP 5000 !terminal_output!<cr>'):format(testprg('shell-test'))) - feed('G') -- Follow :terminal output. - feed([[:sign <Tab>]]) -- Invoke wildmenu. + feed('G') -- Follow :terminal output. + feed([[:sign <Tab>]]) -- Invoke wildmenu. -- NB: in earlier versions terminal output was redrawn during cmdline mode. -- For now just assert that the screen remains unchanged. - screen:expect{any='define jump list > |\n:sign define^ |'} + screen:expect { any = 'define jump list > |\n:sign define^ |' } screen:expect_unchanged() -- cmdline CTRL-D display should also be preserved. feed([[<C-U>]]) - feed([[sign <C-D>]]) -- Invoke cmdline CTRL-D. - screen:expect{grid=[[ + feed([[sign <C-D>]]) -- Invoke cmdline CTRL-D. + screen:expect { + grid = [[ :sign | define place | jump undefine | list unplace | :sign ^ | - ]]} + ]], + } screen:expect_unchanged() -- Exiting cmdline should show the buffer. feed([[<C-\><C-N>]]) - screen:expect{any=[[!terminal_output!]]} + screen:expect { any = [[!terminal_output!]] } end) it('ignores :redrawstatus called from a timer #7108', function() command('set wildmenu wildmode=full') command([[call timer_start(10, {->execute('redrawstatus')}, {'repeat':-1})]]) feed([[<C-\><C-N>]]) - feed([[:sign <Tab>]]) -- Invoke wildmenu. - screen:expect{grid=[[ + feed([[:sign <Tab>]]) -- Invoke wildmenu. + screen:expect { + grid = [[ | - ~ | - ~ | + ~ |*2 define jump list > | :sign define^ | - ]]} + ]], + } screen:expect_unchanged() end) it('with laststatus=0, :vsplit, :term #2255', function() - -- Because this test verifies a _lack_ of activity after screen:sleep(), we - -- must wait the full timeout. So make it reasonable. - screen.timeout = 1000 - if not is_os('win') then - command('set shell=sh') -- Need a predictable "$" prompt. + command('set shell=sh') -- Need a predictable "$" prompt. command('let $PS1 = "$"') end command('set laststatus=0') @@ -256,11 +249,13 @@ describe("'wildmenu'", function() end) feed([[<C-\><C-N>]]) - feed([[:<Tab>]]) -- Invoke wildmenu. + feed([[:<Tab>]]) -- Invoke wildmenu. -- Check only the last 2 lines, because the shell output is -- system-dependent. - screen:expect{any='! # & < = > @ > |\n:!^'} - screen:expect_unchanged() + screen:expect { any = '! # & < = > @ > |\n:!^' } + -- Because this test verifies a _lack_ of activity, we must wait the full timeout. + -- So make it reasonable. + screen:expect_unchanged(false, 1000) end) it('wildmode=list,full and messages interaction #10092', function() @@ -282,21 +277,16 @@ describe("'wildmenu'", function() feed('<tab>') -- trigger wildmode full screen:expect([[ [No Name] | - | - | + |*2 :set wildm | - wildmenu wildmode | - wildmenu wildmode | + wildmenu wildmode |*2 :set wildmenu^ | ]]) feed('<Esc>') screen:expect([[ [No Name] | ^ | - ~ | - ~ | - ~ | - ~ | + ~ |*4 | ]]) end) @@ -311,18 +301,13 @@ describe("'wildmenu'", function() feed(':sign u<tab>') screen:expect([[ | - ~ | - ~ | - ~ | - ~ | - ~ | + ~ |*5 :sign un^ | ]]) feed('<tab>') -- trigger wildmode list screen:expect([[ | - ~ | - ~ | + ~ |*2 | :sign un | undefine unplace | @@ -331,11 +316,7 @@ describe("'wildmenu'", function() feed('<Esc>') screen:expect([[ ^ | - ~ | - ~ | - ~ | - ~ | - ~ | + ~ |*5 | ]]) @@ -343,8 +324,7 @@ describe("'wildmenu'", function() feed(':sign un<tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 | :sign un | undefine unplace | @@ -355,11 +335,7 @@ describe("'wildmenu'", function() feed('<Esc>') screen:expect([[ ^ | - ~ | - ~ | - ~ | - ~ | - ~ | + ~ |*5 | ]]) end) @@ -372,8 +348,7 @@ describe("'wildmenu'", function() feed(':sign u<tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 | :sign u | undefine unplace | @@ -382,8 +357,7 @@ describe("'wildmenu'", function() feed('<tab>') -- trigger wildmode longest screen:expect([[ | - ~ | - ~ | + ~ |*2 | :sign u | undefine unplace | @@ -392,11 +366,7 @@ describe("'wildmenu'", function() feed('<Esc>') screen:expect([[ ^ | - ~ | - ~ | - ~ | - ~ | - ~ | + ~ |*5 | ]]) end) @@ -409,8 +379,7 @@ describe("'wildmenu'", function() feed('<c-d>') screen:expect([[ | - ~ | - ~ | + ~ |*2 | :set wildm | wildmenu wildmode | @@ -418,8 +387,7 @@ describe("'wildmenu'", function() ]]) feed('<c-d>') screen:expect([[ - | - | + |*2 :set wildm | wildmenu wildmode | :set wildm | @@ -429,10 +397,7 @@ describe("'wildmenu'", function() feed('<Esc>') screen:expect([[ ^ | - ~ | - ~ | - ~ | - ~ | + ~ |*4 [No Name] | | ]]) @@ -440,28 +405,29 @@ describe("'wildmenu'", function() it('works with c_CTRL_Z standard mapping', function() 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}; + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey0, background = Screen.colors.Yellow }, + [3] = { bold = true, reverse = true }, } -- Wildcharm? where we are going we aint't no need no wildcharm. - eq(0, meths.get_option_value('wildcharm', {})) + eq(0, api.nvim_get_option_value('wildcharm', {})) -- Don't mess the defaults yet (neovim is about backwards compatibility) - eq(9, meths.get_option_value('wildchar', {})) + eq(9, api.nvim_get_option_value('wildchar', {})) -- Lol what is cnoremap? Some say it can define mappings. command 'set wildchar=0' - eq(0, meths.get_option_value('wildchar', {})) + eq(0, api.nvim_get_option_value('wildchar', {})) command 'cnoremap <f2> <c-z>' feed(':syntax <f2>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:case}{3: clear cluster > }| :syntax case^ | - ]]} + ]], + } feed '<esc>' command 'set wildmode=longest:full,full' @@ -469,31 +435,32 @@ describe("'wildmenu'", function() command [[cnoremap <expr> <tab> luaeval("not rawset(_G, 'coin', not coin).coin") ? "<c-z>" : "c"]] feed ':syntax <tab>' - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :syntax c^ | - ]]} + ]], + } feed '<tab>' - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:case clear cluster > }| :syntax c^ | - ]]} + ]], + } feed '<tab>' - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :syntax cc^ | - ]]} + ]], + } end) end) @@ -503,9 +470,9 @@ describe('command line completion', 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}, + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey0, background = Screen.colors.Yellow }, + [3] = { bold = true, reverse = true }, }) screen:attach() end) @@ -514,17 +481,15 @@ describe('command line completion', function() end) it('lists directories with empty PATH', function() - local tmp = funcs.tempname() - command('e '.. tmp) + local tmp = fn.tempname() + command('e ' .. tmp) command('cd %:h') command("call mkdir('Xtest-functional-viml-compl-dir')") command('let $PATH=""') feed(':!<tab><bs>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :!Xtest-functional-viml-compl-dir^ | ]]) end) @@ -535,71 +500,63 @@ describe('command line completion', function() feed(':!echo $XTEST_<tab>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:XTEST_1}{3: XTEST_2 }| :!echo $XTEST_1^ | ]]) end) it('completes (multibyte) env var names #9655', function() - clear({env={ - ['XTEST_1AaあB']='foo', - ['XTEST_2']='bar', - }}) + clear({ env = { + ['XTEST_1AaあB'] = 'foo', + ['XTEST_2'] = 'bar', + } }) screen:attach() command('set wildmenu wildmode=full') feed(':!echo $XTEST_<tab>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:XTEST_1AaあB}{3: XTEST_2 }| :!echo $XTEST_1AaあB^ | ]]) end) it('does not leak memory with <S-Tab> with wildmenu and only one match #19874', function() - meths.set_option_value('wildmenu', true, {}) - meths.set_option_value('wildmode', 'full', {}) - meths.set_option_value('wildoptions', 'pum', {}) + api.nvim_set_option_value('wildmenu', true, {}) + api.nvim_set_option_value('wildmode', 'full', {}) + api.nvim_set_option_value('wildoptions', 'pum', {}) feed(':sign unpla<S-Tab>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :sign unplace^ | ]]) feed('<Space>buff<Tab>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :sign unplace buffer=^ | ]]) end) it('does not show matches with <S-Tab> without wildmenu with wildmode=full', function() - meths.set_option_value('wildmenu', false, {}) - meths.set_option_value('wildmode', 'full', {}) + api.nvim_set_option_value('wildmenu', false, {}) + api.nvim_set_option_value('wildmode', 'full', {}) feed(':sign <S-Tab>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :sign unplace^ | ]]) end) it('shows matches with <S-Tab> without wildmenu with wildmode=list', function() - meths.set_option_value('wildmenu', false, {}) - meths.set_option_value('wildmode', 'list', {}) + api.nvim_set_option_value('wildmenu', false, {}) + api.nvim_set_option_value('wildmode', 'list', {}) feed(':sign <S-Tab>') screen:expect([[ @@ -618,64 +575,72 @@ describe('ui/ext_wildmenu', function() before_each(function() clear() screen = Screen.new(25, 5) - screen:attach({rgb=true, ext_wildmenu=true}) + screen:attach({ rgb = true, ext_wildmenu = true }) end) it('works with :sign <tab>', function() local expected = { - 'define', - 'jump', - 'list', - 'place', - 'undefine', - 'unplace', + 'define', + 'jump', + 'list', + 'place', + 'undefine', + 'unplace', } command('set wildmode=full') command('set wildmenu') feed(':sign <tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - ~ | - ~ | - ~ | + ~ |*3 :sign define^ | - ]], wildmenu_items=expected, wildmenu_pos=0} + ]], + wildmenu_items = expected, + wildmenu_pos = 0, + } feed('<tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - ~ | - ~ | - ~ | + ~ |*3 :sign jump^ | - ]], wildmenu_items=expected, wildmenu_pos=1} + ]], + wildmenu_items = expected, + wildmenu_pos = 1, + } feed('<left><left>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - ~ | - ~ | - ~ | + ~ |*3 :sign ^ | - ]], wildmenu_items=expected, wildmenu_pos=-1} + ]], + wildmenu_items = expected, + wildmenu_pos = -1, + } feed('<right>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - ~ | - ~ | - ~ | + ~ |*3 :sign define^ | - ]], wildmenu_items=expected, wildmenu_pos=0} + ]], + wildmenu_items = expected, + wildmenu_pos = 0, + } feed('a') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - ~ | - ~ | - ~ | + ~ |*3 :sign definea^ | - ]]} + ]], + } end) end) |