Files
neovim/test/functional/ui/cmdline_spec.lua

201 lines
5.4 KiB
Lua
Raw Normal View History

2017-02-24 07:26:39 +00:00
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
2017-02-27 02:56:38 +00:00
local clear, feed, eq = helpers.clear, helpers.feed, helpers.eq
2017-02-24 07:26:39 +00:00
if helpers.pending_win32(pending) then return end
describe('External command line completion', function()
local screen
local shown = false
local firstc, prompt, content, pos, char, shift, level, current_hide_level, in_function
2017-02-24 07:26:39 +00:00
before_each(function()
clear()
screen = Screen.new(25, 5)
screen:attach({rgb=true, ext_cmdline=true})
2017-02-24 07:26:39 +00:00
screen:set_on_event_handler(function(name, data)
if name == "cmdline_hide" then
2017-02-24 07:26:39 +00:00
shown = false
current_hide_level = data[1]
elseif name == "cmdline_show" then
shown = true
content, pos, firstc, prompt, level = unpack(data)
elseif name == "cmdline_char" then
char, shift = unpack(data)
2017-02-24 07:26:39 +00:00
elseif name == "cmdline_pos" then
pos = data[1]
elseif name == "cmdline_function_show" then
in_function = true
elseif name == "cmdline_function_hide" then
in_function = false
2017-02-24 07:26:39 +00:00
end
end)
end)
after_each(function()
screen:detach()
end)
describe("'cmdline'", function()
it(':sign', function()
feed(':')
screen:expect([[
^ |
~ |
~ |
~ |
|
]], nil, nil, function()
eq(true, shown)
eq(':', firstc)
end)
feed('sign')
screen:expect([[
^ |
~ |
~ |
~ |
|
]], nil, nil, function()
2017-04-28 07:49:45 +01:00
eq({{'Normal', 'sign'}}, content)
2017-02-24 07:26:39 +00:00
eq(4, pos)
end)
feed('<Left>')
screen:expect([[
^ |
~ |
~ |
~ |
|
]], nil, nil, function()
2017-04-28 07:49:45 +01:00
eq({{'Normal', 'sign'}}, content)
2017-02-24 07:26:39 +00:00
eq(true, shown)
eq(3, pos)
end)
feed('<bs>')
screen:expect([[
^ |
~ |
~ |
~ |
|
]], nil, nil, function()
2017-04-28 07:49:45 +01:00
eq({{'Normal', 'sin'}}, content)
2017-02-24 07:26:39 +00:00
eq(true, shown)
eq(2, pos)
end)
feed('<Esc>')
screen:expect([[
^ |
~ |
~ |
~ |
|
]], nil, nil, function()
eq(false, shown)
end)
feed(':call input("input", "default")<cr>')
screen:expect([[
^ |
~ |
~ |
~ |
|
]], nil, nil, function()
eq(true, shown)
eq("input", prompt)
2017-04-28 07:49:45 +01:00
eq({{'Normal', 'default'}}, content)
2017-02-24 07:26:39 +00:00
end)
feed('<cr>')
feed(':')
2017-02-24 07:26:39 +00:00
screen:expect([[
^ |
~ |
~ |
~ |
|
]], nil, nil, function()
eq(1, level)
end)
feed('<C-R>=1+2')
screen:expect([[
^ |
~ |
~ |
~ |
|
]], nil, nil, function()
eq({{'Normal', '1+2'}}, content)
eq("\"", char)
eq(1, shift)
eq(2, level)
end)
feed('<cr>')
screen:expect([[
^ |
~ |
~ |
~ |
|
]], nil, nil, function()
eq({{'Normal', '3'}}, content)
eq(2, current_hide_level)
eq(1, level)
end)
feed('<esc>')
screen:expect([[
^ |
~ |
~ |
~ |
|
]], nil, nil, function()
eq(1, current_hide_level)
2017-02-24 07:26:39 +00:00
end)
feed(':function Foo()<cr>')
screen:expect([[
^ |
~ |
~ |
~ |
|
]], nil, nil, function()
eq(true, in_function)
end)
feed('line1<cr>')
screen:expect([[
^ |
~ |
~ |
~ |
|
]], nil, nil, function()
eq(true, in_function)
end)
feed('endfunction<cr>')
screen:expect([[
^ |
~ |
~ |
~ |
|
]], nil, nil, function()
eq(false, in_function)
end)
2017-02-24 07:26:39 +00:00
end)
end)
end)