123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593 |
- 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 iswin = helpers.iswin
- local funcs = helpers.funcs
- local meths = helpers.meths
- local eq = helpers.eq
- local eval = helpers.eval
- local retry = helpers.retry
- local nvim_dir = helpers.nvim_dir
- describe("'wildmenu'", function()
- local screen
- before_each(function()
- clear()
- screen = Screen.new(25, 5)
- screen:attach()
- end)
- it('C-E to cancel wildmenu completion restore original input', function()
- feed(':sign <tab>')
- screen:expect([[
- |
- ~ |
- ~ |
- define jump list > |
- :sign define^ |
- ]])
- feed('<C-E>')
- screen:expect([[
- |
- ~ |
- ~ |
- ~ |
- :sign ^ |
- ]])
- end)
- it('C-Y to apply selection and end wildmenu completion', function()
- feed(':sign <tab>')
- screen:expect([[
- |
- ~ |
- ~ |
- define jump list > |
- :sign define^ |
- ]])
- feed('<tab><C-Y>')
- screen:expect([[
- |
- ~ |
- ~ |
- ~ |
- :sign jump^ |
- ]])
- end)
- it(':sign <tab> shows wildmenu completions', function()
- command('set wildmenu wildmode=full')
- feed(':sign <tab>')
- screen:expect([[
- |
- ~ |
- ~ |
- define jump list > |
- :sign define^ |
- ]])
- end)
- it(':sign <tab> <space> hides wildmenu #8453', function()
- command('set wildmode=full')
- -- only a regression if status-line open
- command('set laststatus=2')
- command('set wildmenu')
- feed(':sign <tab>')
- screen:expect([[
- |
- ~ |
- ~ |
- define jump list > |
- :sign define^ |
- ]])
- feed('<space>')
- screen:expect([[
- |
- ~ |
- ~ |
- [No Name] |
- :sign define ^ |
- ]])
- end)
- it('does not crash after cycling back to original text', function()
- command('set wildmode=full')
- feed(':j<Tab><Tab><Tab>')
- screen:expect([[
- |
- ~ |
- ~ |
- join jumps |
- :j^ |
- ]])
- -- This would cause nvim to crash before #6650
- feed('<BS><Tab>')
- screen:expect([[
- |
- ~ |
- ~ |
- ! # & < = > @ > |
- :!^ |
- ]])
- end)
- it('is preserved during :terminal activity', function()
- command('set wildmenu wildmode=full')
- command('set scrollback=4')
- feed([[:terminal "]]..nvim_dir..[[/shell-test" REP 5000 !terminal_output!<cr>]])
- 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_unchanged()
- -- cmdline CTRL-D display should also be preserved.
- feed([[<C-U>]])
- 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!]]}
- 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=[[
- |
- ~ |
- ~ |
- 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 iswin() then
- command('set shell=sh') -- Need a predictable "$" prompt.
- command('let $PS1 = "$"')
- end
- command('set laststatus=0')
- command('vsplit')
- command('term')
- -- Check for a shell prompt to verify that the terminal loaded.
- retry(nil, nil, function()
- if iswin() then
- eq('Microsoft', eval("matchstr(join(getline(1, '$')), 'Microsoft')"))
- else
- eq('$', eval([[matchstr(getline(1), '\$')]]))
- end
- end)
- feed([[<C-\><C-N>]])
- feed([[:<Tab>]]) -- Invoke wildmenu.
- -- Check only the last 2 lines, because the shell output is
- -- system-dependent.
- screen:expect{any='! # & < = > @ > |\n:!^'}
- screen:expect_unchanged()
- end)
- it('wildmode=list,full and display+=msgsep interaction #10092', function()
- -- Need more than 5 rows, else tabline is covered and will be redrawn.
- screen:try_resize(25, 7)
- command('set display+=msgsep')
- command('set wildmenu wildmode=list,full')
- command('set showtabline=2')
- feed(':set wildm<tab>')
- screen:expect([[
- [No Name] |
- |
- ~ |
- |
- :set wildm |
- wildmenu wildmode |
- :set wildm^ |
- ]])
- feed('<tab>') -- trigger wildmode full
- screen:expect([[
- [No Name] |
- |
- |
- :set wildm |
- wildmenu wildmode |
- wildmenu wildmode |
- :set wildmenu^ |
- ]])
- feed('<Esc>')
- screen:expect([[
- [No Name] |
- ^ |
- ~ |
- ~ |
- ~ |
- ~ |
- |
- ]])
- end)
- it('wildmode=list,full and display-=msgsep interaction', function()
- -- Need more than 5 rows, else tabline is covered and will be redrawn.
- screen:try_resize(25, 7)
- command('set display-=msgsep')
- command('set wildmenu wildmode=list,full')
- feed(':set wildm<tab>')
- screen:expect([[
- ~ |
- ~ |
- ~ |
- ~ |
- :set wildm |
- wildmenu wildmode |
- :set wildm^ |
- ]])
- feed('<tab>') -- trigger wildmode full
- screen:expect([[
- ~ |
- ~ |
- ~ |
- :set wildm |
- wildmenu wildmode |
- wildmenu wildmode |
- :set wildmenu^ |
- ]])
- feed('<Esc>')
- screen:expect([[
- ^ |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- |
- ]])
- end)
- it('wildmode=longest,list', function()
- -- Need more than 5 rows, else tabline is covered and will be redrawn.
- screen:try_resize(25, 7)
- command('set wildmenu wildmode=longest,list')
- -- give wildmode-longest something to expand to
- feed(':sign u<tab>')
- screen:expect([[
- |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- :sign un^ |
- ]])
- feed('<tab>') -- trigger wildmode list
- screen:expect([[
- |
- ~ |
- ~ |
- |
- :sign un |
- undefine unplace |
- :sign un^ |
- ]])
- feed('<Esc>')
- screen:expect([[
- ^ |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- |
- ]])
- -- give wildmode-longest something it cannot expand, use list
- feed(':sign un<tab>')
- screen:expect([[
- |
- ~ |
- ~ |
- |
- :sign un |
- undefine unplace |
- :sign un^ |
- ]])
- feed('<tab>')
- screen:expect_unchanged()
- feed('<Esc>')
- screen:expect([[
- ^ |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- |
- ]])
- end)
- it('wildmode=list,longest', function()
- -- Need more than 5 rows, else tabline is covered and will be redrawn.
- screen:try_resize(25, 7)
- command('set wildmenu wildmode=list,longest')
- feed(':sign u<tab>')
- screen:expect([[
- |
- ~ |
- ~ |
- |
- :sign u |
- undefine unplace |
- :sign u^ |
- ]])
- feed('<tab>') -- trigger wildmode longest
- screen:expect([[
- |
- ~ |
- ~ |
- |
- :sign u |
- undefine unplace |
- :sign un^ |
- ]])
- feed('<Esc>')
- screen:expect([[
- ^ |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- |
- ]])
- end)
- it('multiple <C-D> renders correctly', function()
- screen:try_resize(25, 7)
- command('set laststatus=2')
- command('set display+=msgsep')
- feed(':set wildm')
- feed('<c-d>')
- screen:expect([[
- |
- ~ |
- ~ |
- |
- :set wildm |
- wildmenu wildmode |
- :set wildm^ |
- ]])
- feed('<c-d>')
- screen:expect([[
- |
- |
- :set wildm |
- wildmenu wildmode |
- :set wildm |
- wildmenu wildmode |
- :set wildm^ |
- ]])
- feed('<Esc>')
- screen:expect([[
- ^ |
- ~ |
- ~ |
- ~ |
- ~ |
- [No Name] |
- |
- ]])
- end)
- 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};
- }
- -- Wildcharm? where we are going we aint't no need no wildcharm.
- eq(0, meths.get_option'wildcharm')
- -- Don't mess the defaults yet (neovim is about backwards compatibility)
- eq(9, meths.get_option'wildchar')
- -- Lol what is cnoremap? Some say it can define mappings.
- command 'set wildchar=0'
- eq(0, meths.get_option'wildchar')
- command 'cnoremap <f2> <c-z>'
- feed(':syntax <f2>')
- screen:expect{grid=[[
- |
- {1:~ }|
- {1:~ }|
- {2:case}{3: clear cluster > }|
- :syntax case^ |
- ]]}
- feed '<esc>'
- command 'set wildmode=longest:full,full'
- -- this will get cleaner once we have native lua expr mappings:
- command [[cnoremap <expr> <tab> luaeval("not rawset(_G, 'coin', not coin).coin") ? "<c-z>" : "c"]]
- feed ':syntax <tab>'
- screen:expect{grid=[[
- |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- :syntax c^ |
- ]]}
- feed '<tab>'
- screen:expect{grid=[[
- |
- {1:~ }|
- {1:~ }|
- {3:case clear cluster > }|
- :syntax c^ |
- ]]}
- feed '<tab>'
- screen:expect{grid=[[
- |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- :syntax cc^ |
- ]]}
- end)
- end)
- describe('command line completion', function()
- local screen
- before_each(function()
- 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},
- })
- 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')
- command("call mkdir('Xtest-functional-viml-compl-dir')")
- command('let $PATH=""')
- feed(':!<tab><bs>')
- screen:expect([[
- |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- :!Xtest-functional-viml-compl-dir^ |
- ]])
- 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>')
- screen:expect([[
- |
- {1:~ }|
- {1:~ }|
- {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',
- }})
- screen:attach()
- command('set wildmenu wildmode=full')
- feed(':!echo $XTEST_<tab>')
- screen:expect([[
- |
- {1:~ }|
- {1:~ }|
- {2:XTEST_1AaあB}{3: XTEST_2 }|
- :!echo $XTEST_1AaあB^ |
- ]])
- end)
- end)
- describe('ui/ext_wildmenu', function()
- local screen
- before_each(function()
- clear()
- screen = Screen.new(25, 5)
- screen:attach({rgb=true, ext_wildmenu=true})
- end)
- it('works with :sign <tab>', function()
- local expected = {
- 'define',
- 'jump',
- 'list',
- 'place',
- 'undefine',
- 'unplace',
- }
- command('set wildmode=full')
- command('set wildmenu')
- feed(':sign <tab>')
- screen:expect{grid=[[
- |
- ~ |
- ~ |
- ~ |
- :sign define^ |
- ]], wildmenu_items=expected, wildmenu_pos=0}
- feed('<tab>')
- screen:expect{grid=[[
- |
- ~ |
- ~ |
- ~ |
- :sign jump^ |
- ]], wildmenu_items=expected, wildmenu_pos=1}
- feed('<left><left>')
- screen:expect{grid=[[
- |
- ~ |
- ~ |
- ~ |
- :sign ^ |
- ]], wildmenu_items=expected, wildmenu_pos=-1}
- feed('<right>')
- screen:expect{grid=[[
- |
- ~ |
- ~ |
- ~ |
- :sign define^ |
- ]], wildmenu_items=expected, wildmenu_pos=0}
- feed('a')
- screen:expect{grid=[[
- |
- ~ |
- ~ |
- ~ |
- :sign definea^ |
- ]]}
- end)
- end)
|