2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2015-02-14 18:16:39 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2017-04-08 14:12:26 -07:00
|
|
|
local clear, feed, command = helpers.clear, helpers.feed, helpers.command
|
2017-08-05 17:44:15 -07:00
|
|
|
local iswin = helpers.iswin
|
2016-05-01 12:47:10 -07:00
|
|
|
local funcs = helpers.funcs
|
2017-08-02 15:41:52 -07:00
|
|
|
local eq = helpers.eq
|
|
|
|
local eval = helpers.eval
|
|
|
|
local retry = helpers.retry
|
2015-02-14 18:16:39 -07:00
|
|
|
|
2017-08-02 15:41:52 -07:00
|
|
|
describe("'wildmenu'", function()
|
2015-02-14 18:16:39 -07:00
|
|
|
local screen
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
screen = Screen.new(25, 5)
|
|
|
|
screen:attach()
|
|
|
|
end)
|
|
|
|
after_each(function()
|
|
|
|
screen:detach()
|
|
|
|
end)
|
|
|
|
|
2017-08-02 15:41:52 -07:00
|
|
|
it(':sign <tab> shows wildmenu completions', function()
|
|
|
|
command('set wildmode=full')
|
|
|
|
command('set wildmenu')
|
|
|
|
feed(':sign <tab>')
|
|
|
|
screen:expect([[
|
|
|
|
|
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
define jump list > |
|
|
|
|
: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()
|
|
|
|
-- Because this test verifies a _lack_ of activity after screen:sleep(), we
|
|
|
|
-- must wait the full timeout. So make it reasonable.
|
|
|
|
screen.timeout = 1000
|
2017-05-03 01:12:38 -07:00
|
|
|
|
2017-08-02 15:41:52 -07:00
|
|
|
command('set wildmenu wildmode=full')
|
|
|
|
command('set scrollback=4')
|
|
|
|
if iswin() then
|
2018-02-17 00:25:51 -07:00
|
|
|
feed([[:terminal for /L \%I in (1,1,5000) do @(echo foo & echo foo & echo foo)<cr>]])
|
2017-08-02 15:41:52 -07:00
|
|
|
else
|
|
|
|
feed([[:terminal for i in $(seq 1 5000); do printf 'foo\nfoo\nfoo\n'; sleep 0.1; done<cr>]])
|
|
|
|
end
|
2017-08-04 18:34:38 -07:00
|
|
|
|
2017-08-02 15:41:52 -07:00
|
|
|
feed([[<C-\><C-N>gg]])
|
|
|
|
feed([[:sign <Tab>]]) -- Invoke wildmenu.
|
2018-02-17 00:25:51 -07:00
|
|
|
screen:sleep(50) -- Allow some terminal output.
|
2017-08-02 15:41:52 -07:00
|
|
|
screen:expect([[
|
|
|
|
foo |
|
|
|
|
foo |
|
|
|
|
foo |
|
|
|
|
define jump list > |
|
|
|
|
:sign define^ |
|
|
|
|
]])
|
2017-08-04 18:34:38 -07:00
|
|
|
|
|
|
|
-- cmdline CTRL-D display should also be preserved.
|
|
|
|
feed([[<C-\><C-N>]])
|
|
|
|
feed([[:sign <C-D>]]) -- Invoke cmdline CTRL-D.
|
2018-02-17 00:25:51 -07:00
|
|
|
screen:sleep(50) -- Allow some terminal output.
|
2017-08-04 18:34:38 -07:00
|
|
|
screen:expect([[
|
|
|
|
:sign |
|
|
|
|
define place |
|
|
|
|
jump undefine |
|
|
|
|
list unplace |
|
|
|
|
:sign ^ |
|
|
|
|
]])
|
|
|
|
|
|
|
|
-- Exiting cmdline should show the buffer.
|
|
|
|
feed([[<C-\><C-N>]])
|
|
|
|
screen:expect([[
|
|
|
|
^foo |
|
|
|
|
foo |
|
|
|
|
foo |
|
|
|
|
foo |
|
|
|
|
|
|
|
|
|
]])
|
2017-08-02 15:41:52 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('ignores :redrawstatus called from a timer #7108', 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
|
|
|
|
|
|
|
|
command('set wildmenu wildmode=full')
|
|
|
|
command([[call timer_start(10, {->execute('redrawstatus')}, {'repeat':-1})]])
|
|
|
|
feed([[<C-\><C-N>]])
|
|
|
|
feed([[:sign <Tab>]]) -- Invoke wildmenu.
|
|
|
|
screen:sleep(30) -- Allow some timer activity.
|
|
|
|
screen:expect([[
|
|
|
|
|
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
define jump list > |
|
|
|
|
:sign define^ |
|
|
|
|
]])
|
|
|
|
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
|
|
|
|
|
2017-08-05 17:44:15 -07:00
|
|
|
if not iswin() then
|
|
|
|
command('set shell=sh') -- Need a predictable "$" prompt.
|
2017-08-02 15:41:52 -07:00
|
|
|
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
|
2017-08-05 17:44:15 -07:00
|
|
|
eq('Microsoft', eval("matchstr(join(getline(1, '$')), 'Microsoft')"))
|
2017-08-02 15:41:52 -07:00
|
|
|
else
|
|
|
|
eq('$', eval([[matchstr(getline(1), '\$')]]))
|
|
|
|
end
|
2017-05-03 01:12:38 -07:00
|
|
|
end)
|
2017-08-02 15:41:52 -07:00
|
|
|
|
|
|
|
feed([[<C-\><C-N>]])
|
|
|
|
feed([[:<Tab>]]) -- Invoke wildmenu.
|
|
|
|
screen:sleep(10) -- Flush
|
|
|
|
-- Check only the last 2 lines, because the shell output is
|
|
|
|
-- system-dependent.
|
|
|
|
screen:expect('! # & < = > @ > \n:!^', nil, nil, nil, true)
|
2015-02-14 18:16:39 -07:00
|
|
|
end)
|
|
|
|
end)
|
2016-05-01 12:47:10 -07:00
|
|
|
|
|
|
|
describe('command line completion', function()
|
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
screen = Screen.new(40, 5)
|
|
|
|
screen:attach()
|
2016-08-09 06:11:04 -07:00
|
|
|
screen:set_default_attr_ids({[1]={bold=true, foreground=Screen.colors.Blue}})
|
2016-05-01 12:47:10 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
after_each(function()
|
|
|
|
os.remove('Xtest-functional-viml-compl-dir')
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('lists directories with empty PATH', function()
|
|
|
|
local tmp = funcs.tempname()
|
2017-04-08 14:12:26 -07:00
|
|
|
command('e '.. tmp)
|
|
|
|
command('cd %:h')
|
|
|
|
command("call mkdir('Xtest-functional-viml-compl-dir')")
|
|
|
|
command('let $PATH=""')
|
2016-05-01 12:47:10 -07:00
|
|
|
feed(':!<tab><bs>')
|
|
|
|
screen:expect([[
|
|
|
|
|
|
2016-08-09 06:11:04 -07:00
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
2016-05-01 12:47:10 -07:00
|
|
|
:!Xtest-functional-viml-compl-dir^ |
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
2017-02-23 23:12:34 -07:00
|
|
|
|
2017-10-31 02:45:06 -07:00
|
|
|
describe('ui/ext_wildmenu', function()
|
2017-02-23 23:12:34 -07:00
|
|
|
local screen
|
|
|
|
local items, selected = nil, nil
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
screen = Screen.new(25, 5)
|
|
|
|
screen:attach({rgb=true, ext_wildmenu=true})
|
|
|
|
screen:set_on_event_handler(function(name, data)
|
|
|
|
if name == "wildmenu_show" then
|
|
|
|
items = data[1]
|
|
|
|
elseif name == "wildmenu_select" then
|
|
|
|
selected = data[1]
|
|
|
|
elseif name == "wildmenu_hide" then
|
|
|
|
items, selected = nil, nil
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
after_each(function()
|
|
|
|
screen:detach()
|
|
|
|
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([[
|
|
|
|
|
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
:sign define^ |
|
|
|
|
]], nil, nil, function()
|
|
|
|
eq(expected, items)
|
|
|
|
eq(0, selected)
|
|
|
|
end)
|
|
|
|
|
|
|
|
feed('<tab>')
|
|
|
|
screen:expect([[
|
|
|
|
|
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
:sign jump^ |
|
|
|
|
]], nil, nil, function()
|
|
|
|
eq(expected, items)
|
|
|
|
eq(1, selected)
|
|
|
|
end)
|
|
|
|
|
|
|
|
feed('<left><left>')
|
|
|
|
screen:expect([[
|
|
|
|
|
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
:sign ^ |
|
|
|
|
]], nil, nil, function()
|
|
|
|
eq(expected, items)
|
|
|
|
eq(-1, selected)
|
|
|
|
end)
|
|
|
|
|
|
|
|
feed('<right>')
|
|
|
|
screen:expect([[
|
|
|
|
|
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
:sign define^ |
|
|
|
|
]], nil, nil, function()
|
|
|
|
eq(expected, items)
|
|
|
|
eq(0, selected)
|
|
|
|
end)
|
|
|
|
|
|
|
|
feed('a')
|
|
|
|
screen:expect([[
|
|
|
|
|
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
:sign definea^ |
|
|
|
|
]], nil, nil, function()
|
|
|
|
eq(nil, items)
|
|
|
|
eq(nil, selected)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|