2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2021-01-04 11:04:21 -07:00
|
|
|
local clear, feed_command = helpers.clear, helpers.feed_command
|
2018-03-08 16:24:38 -07:00
|
|
|
local feed, next_msg, eq = helpers.feed, helpers.next_msg, helpers.eq
|
2018-03-31 02:12:27 -07:00
|
|
|
local command = helpers.command
|
2015-02-18 09:16:30 -07:00
|
|
|
local expect = helpers.expect
|
2022-03-23 03:58:47 -07:00
|
|
|
local curbuf_contents = helpers.curbuf_contents
|
2021-01-04 11:04:21 -07:00
|
|
|
local meths = helpers.meths
|
|
|
|
local exec_lua = helpers.exec_lua
|
2018-02-27 02:02:04 -07:00
|
|
|
local write_file = helpers.write_file
|
2022-04-08 22:31:42 -07:00
|
|
|
local funcs = helpers.funcs
|
2015-09-25 06:30:20 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2014-12-08 18:31:45 -07:00
|
|
|
|
2021-01-04 11:04:21 -07:00
|
|
|
before_each(clear)
|
2014-12-08 18:31:45 -07:00
|
|
|
|
2021-01-04 11:04:21 -07:00
|
|
|
describe('mappings', function()
|
2014-12-08 18:31:45 -07:00
|
|
|
local add_mapping = function(mapping, send)
|
2021-01-04 11:04:21 -07:00
|
|
|
local cmd = "nnoremap "..mapping.." :call rpcnotify(1, 'mapped', '"
|
2014-12-08 18:31:45 -07:00
|
|
|
..send:gsub('<', '<lt>').."')<cr>"
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command(cmd)
|
2014-12-08 18:31:45 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
local check_mapping = function(mapping, expected)
|
|
|
|
feed(mapping)
|
2018-03-08 16:24:38 -07:00
|
|
|
eq({'notification', 'mapped', {expected}}, next_msg())
|
2014-12-08 18:31:45 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
before_each(function()
|
2020-07-03 22:10:32 -07:00
|
|
|
add_mapping('<C-L>', '<C-L>')
|
|
|
|
add_mapping('<C-S-L>', '<C-S-L>')
|
2014-12-08 18:31:45 -07:00
|
|
|
add_mapping('<s-up>', '<s-up>')
|
|
|
|
add_mapping('<s-up>', '<s-up>')
|
|
|
|
add_mapping('<c-s-up>', '<c-s-up>')
|
|
|
|
add_mapping('<c-s-a-up>', '<c-s-a-up>')
|
2016-02-20 15:09:15 -07:00
|
|
|
add_mapping('<c-s-a-d-up>', '<c-s-a-d-up>')
|
|
|
|
add_mapping('<c-d-a>', '<c-d-a>')
|
|
|
|
add_mapping('<d-1>', '<d-1>')
|
2019-03-26 12:44:59 -07:00
|
|
|
add_mapping('<khome>','<khome>')
|
|
|
|
add_mapping('<kup>','<kup>')
|
|
|
|
add_mapping('<kpageup>','<kpageup>')
|
|
|
|
add_mapping('<kleft>','<kleft>')
|
|
|
|
add_mapping('<korigin>','<korigin>')
|
|
|
|
add_mapping('<kright>','<kright>')
|
|
|
|
add_mapping('<kend>','<kend>')
|
|
|
|
add_mapping('<kdown>','<kdown>')
|
|
|
|
add_mapping('<kpagedown>','<kpagedown>')
|
|
|
|
add_mapping('<kinsert>','<kinsert>')
|
|
|
|
add_mapping('<kdel>','<kdel>')
|
|
|
|
add_mapping('<kdivide>','<kdivide>')
|
|
|
|
add_mapping('<kmultiply>','<kmultiply>')
|
|
|
|
add_mapping('<kminus>','<kminus>')
|
|
|
|
add_mapping('<kplus>','<kplus>')
|
|
|
|
add_mapping('<kenter>','<kenter>')
|
2019-03-29 05:09:54 -07:00
|
|
|
add_mapping('<kcomma>','<kcomma>')
|
|
|
|
add_mapping('<kequal>','<kequal>')
|
2022-04-10 18:54:59 -07:00
|
|
|
add_mapping('<f38>','<f38>')
|
|
|
|
add_mapping('<f63>','<f63>')
|
2014-12-08 18:31:45 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('ok', function()
|
2020-07-03 22:10:32 -07:00
|
|
|
check_mapping('<C-L>', '<C-L>')
|
|
|
|
check_mapping('<C-S-L>', '<C-S-L>')
|
2014-12-08 18:31:45 -07:00
|
|
|
check_mapping('<s-up>', '<s-up>')
|
|
|
|
check_mapping('<c-s-up>', '<c-s-up>')
|
|
|
|
check_mapping('<s-c-up>', '<c-s-up>')
|
|
|
|
check_mapping('<c-s-a-up>', '<c-s-a-up>')
|
|
|
|
check_mapping('<s-c-a-up>', '<c-s-a-up>')
|
|
|
|
check_mapping('<c-a-s-up>', '<c-s-a-up>')
|
|
|
|
check_mapping('<s-a-c-up>', '<c-s-a-up>')
|
|
|
|
check_mapping('<a-c-s-up>', '<c-s-a-up>')
|
|
|
|
check_mapping('<a-s-c-up>', '<c-s-a-up>')
|
2016-02-20 15:09:15 -07:00
|
|
|
check_mapping('<c-s-a-d-up>', '<c-s-a-d-up>')
|
|
|
|
check_mapping('<s-a-d-c-up>', '<c-s-a-d-up>')
|
|
|
|
check_mapping('<d-s-a-c-up>', '<c-s-a-d-up>')
|
|
|
|
check_mapping('<c-d-a>', '<c-d-a>')
|
|
|
|
check_mapping('<d-c-a>', '<c-d-a>')
|
|
|
|
check_mapping('<d-1>', '<d-1>')
|
2019-03-26 12:44:59 -07:00
|
|
|
check_mapping('<khome>','<khome>')
|
|
|
|
check_mapping('<KP7>','<khome>')
|
|
|
|
check_mapping('<kup>','<kup>')
|
|
|
|
check_mapping('<KP8>','<kup>')
|
|
|
|
check_mapping('<kpageup>','<kpageup>')
|
|
|
|
check_mapping('<KP9>','<kpageup>')
|
|
|
|
check_mapping('<kleft>','<kleft>')
|
|
|
|
check_mapping('<KP4>','<kleft>')
|
|
|
|
check_mapping('<korigin>','<korigin>')
|
|
|
|
check_mapping('<KP5>','<korigin>')
|
|
|
|
check_mapping('<kright>','<kright>')
|
|
|
|
check_mapping('<KP6>','<kright>')
|
|
|
|
check_mapping('<kend>','<kend>')
|
|
|
|
check_mapping('<KP1>','<kend>')
|
|
|
|
check_mapping('<kdown>','<kdown>')
|
|
|
|
check_mapping('<KP2>','<kdown>')
|
|
|
|
check_mapping('<kpagedown>','<kpagedown>')
|
|
|
|
check_mapping('<KP3>','<kpagedown>')
|
|
|
|
check_mapping('<kinsert>','<kinsert>')
|
|
|
|
check_mapping('<KP0>','<kinsert>')
|
|
|
|
check_mapping('<kdel>','<kdel>')
|
|
|
|
check_mapping('<KPPeriod>','<kdel>')
|
|
|
|
check_mapping('<kdivide>','<kdivide>')
|
|
|
|
check_mapping('<KPDiv>','<kdivide>')
|
|
|
|
check_mapping('<kmultiply>','<kmultiply>')
|
|
|
|
check_mapping('<KPMult>','<kmultiply>')
|
|
|
|
check_mapping('<kminus>','<kminus>')
|
|
|
|
check_mapping('<KPMinus>','<kminus>')
|
|
|
|
check_mapping('<kplus>','<kplus>')
|
|
|
|
check_mapping('<KPPlus>','<kplus>')
|
|
|
|
check_mapping('<kenter>','<kenter>')
|
|
|
|
check_mapping('<KPEnter>','<kenter>')
|
2019-03-29 05:09:54 -07:00
|
|
|
check_mapping('<kcomma>','<kcomma>')
|
|
|
|
check_mapping('<KPComma>','<kcomma>')
|
|
|
|
check_mapping('<kequal>','<kequal>')
|
|
|
|
check_mapping('<KPEquals>','<kequal>')
|
2022-04-10 18:54:59 -07:00
|
|
|
check_mapping('<f38>','<f38>')
|
|
|
|
check_mapping('<f63>','<f63>')
|
2014-12-08 18:31:45 -07:00
|
|
|
end)
|
2019-08-16 03:03:33 -07:00
|
|
|
|
|
|
|
it('support meta + multibyte char mapping', function()
|
|
|
|
add_mapping('<m-ä>', '<m-ä>')
|
|
|
|
check_mapping('<m-ä>', '<m-ä>')
|
|
|
|
end)
|
2014-12-08 18:31:45 -07:00
|
|
|
end)
|
2015-02-18 09:16:30 -07:00
|
|
|
|
2022-01-21 03:08:56 -07:00
|
|
|
describe('input utf sequences that contain K_SPECIAL (0x80)', function()
|
2015-02-18 09:16:30 -07:00
|
|
|
it('ok', function()
|
|
|
|
feed('i…<esc>')
|
|
|
|
expect('…')
|
|
|
|
end)
|
2022-01-21 03:08:56 -07:00
|
|
|
|
|
|
|
it('can be mapped', function()
|
|
|
|
command('inoremap … E280A6')
|
|
|
|
feed('i…<esc>')
|
|
|
|
expect('E280A6')
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('input utf sequences that contain CSI (0x9B)', function()
|
|
|
|
it('ok', function()
|
|
|
|
feed('iě<esc>')
|
|
|
|
expect('ě')
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('can be mapped', function()
|
|
|
|
command('inoremap ě C49B')
|
|
|
|
feed('iě<esc>')
|
|
|
|
expect('C49B')
|
|
|
|
end)
|
2015-02-18 09:16:30 -07:00
|
|
|
end)
|
2018-02-27 02:02:04 -07:00
|
|
|
|
2022-02-02 22:43:48 -07:00
|
|
|
describe('input split utf sequences', function()
|
|
|
|
it('ok', function()
|
|
|
|
local str = '►'
|
|
|
|
feed('i' .. str:sub(1, 1))
|
|
|
|
helpers.sleep(10)
|
|
|
|
feed(str:sub(2, 3))
|
|
|
|
expect('►')
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('can be mapped', function()
|
|
|
|
command('inoremap ► E296BA')
|
|
|
|
local str = '►'
|
|
|
|
feed('i' .. str:sub(1, 1))
|
|
|
|
helpers.sleep(10)
|
|
|
|
feed(str:sub(2, 3))
|
|
|
|
expect('E296BA')
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2022-03-23 03:58:47 -07:00
|
|
|
describe('input pairs', function()
|
|
|
|
describe('<tab> / <c-i>', function()
|
|
|
|
it('ok', function()
|
|
|
|
feed('i<tab><c-i><esc>')
|
|
|
|
eq('\t\t', curbuf_contents())
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('can be mapped', function()
|
|
|
|
command('inoremap <tab> TAB!')
|
|
|
|
command('inoremap <c-i> CTRL-I!')
|
|
|
|
feed('i<tab><c-i><esc>')
|
|
|
|
eq('TAB!CTRL-I!', curbuf_contents())
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('<cr> / <c-m>', function()
|
|
|
|
it('ok', function()
|
|
|
|
feed('iunos<c-m>dos<cr>tres<esc>')
|
|
|
|
eq('unos\ndos\ntres', curbuf_contents())
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('can be mapped', function()
|
|
|
|
command('inoremap <c-m> SNIPPET!')
|
|
|
|
command('inoremap <cr> , and then<cr>')
|
|
|
|
feed('iunos<c-m>dos<cr>tres<esc>')
|
|
|
|
eq('unosSNIPPET!dos, and then\ntres', curbuf_contents())
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('<esc> / <c-[>', function()
|
|
|
|
it('ok', function()
|
|
|
|
feed('2adouble<c-[>asingle<esc>')
|
|
|
|
eq('doubledoublesingle', curbuf_contents())
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('can be mapped', function()
|
|
|
|
command('inoremap <c-[> HALLOJ!')
|
|
|
|
command('inoremap <esc> ,<esc>')
|
|
|
|
feed('2adubbel<c-[>upp<esc>')
|
|
|
|
eq('dubbelHALLOJ!upp,dubbelHALLOJ!upp,', curbuf_contents())
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2022-04-08 22:31:42 -07:00
|
|
|
it('Ctrl-6 is Ctrl-^ vim-patch:8.1.2333', function()
|
|
|
|
command('split aaa')
|
|
|
|
command('edit bbb')
|
|
|
|
feed('<C-6>')
|
|
|
|
eq('aaa', funcs.bufname())
|
|
|
|
end)
|
|
|
|
|
2022-04-25 06:40:46 -07:00
|
|
|
it('typing a simplifiable key at hit-enter prompt triggers mapping vim-patch:8.2.0839', function()
|
|
|
|
local screen = Screen.new(60,8)
|
|
|
|
screen:set_default_attr_ids({
|
|
|
|
[1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
|
|
|
|
[2] = {bold = true, reverse = true}, -- MsgSeparator
|
|
|
|
[3] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg
|
|
|
|
})
|
|
|
|
screen:attach()
|
|
|
|
command([[nnoremap <C-6> <Cmd>echo 'hit ctrl-6'<CR>]])
|
|
|
|
feed_command('ls')
|
|
|
|
screen:expect([[
|
|
|
|
|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{2: }|
|
|
|
|
:ls |
|
|
|
|
1 %a "[No Name]" line 1 |
|
|
|
|
{3:Press ENTER or type command to continue}^ |
|
|
|
|
]])
|
|
|
|
feed('<C-6>')
|
|
|
|
screen:expect([[
|
|
|
|
^ |
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
hit ctrl-6 |
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
2018-02-27 02:02:04 -07:00
|
|
|
describe('input non-printable chars', function()
|
2018-04-11 13:07:00 -07:00
|
|
|
after_each(function()
|
|
|
|
os.remove('Xtest-overwrite')
|
|
|
|
end)
|
|
|
|
|
2018-02-27 02:02:04 -07:00
|
|
|
it("doesn't crash when echoing them back", function()
|
|
|
|
write_file("Xtest-overwrite", [[foobar]])
|
|
|
|
local screen = Screen.new(60,8)
|
|
|
|
screen:set_default_attr_ids({
|
|
|
|
[1] = {bold = true, foreground = Screen.colors.Blue1},
|
|
|
|
[2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
|
|
|
|
[3] = {bold = true, foreground = Screen.colors.SeaGreen4}
|
|
|
|
})
|
|
|
|
screen:attach()
|
2018-06-21 23:18:02 -07:00
|
|
|
command("set display-=msgsep shortmess-=F")
|
2018-02-27 02:02:04 -07:00
|
|
|
|
|
|
|
feed_command("e Xtest-overwrite")
|
|
|
|
screen:expect([[
|
|
|
|
^foobar |
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
2022-02-04 07:17:25 -07:00
|
|
|
"Xtest-overwrite" [noeol] 1L, 6B |
|
2018-02-27 02:02:04 -07:00
|
|
|
]])
|
|
|
|
|
|
|
|
-- The timestamp is in second resolution, wait two seconds to be sure.
|
|
|
|
screen:sleep(2000)
|
|
|
|
write_file("Xtest-overwrite", [[smurf]])
|
|
|
|
feed_command("w")
|
|
|
|
screen:expect([[
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
"Xtest-overwrite" |
|
|
|
|
{2:WARNING: The file has been changed since reading it!!!} |
|
|
|
|
{3:Do you really want to write to it (y/n)?}^ |
|
|
|
|
]])
|
|
|
|
|
|
|
|
feed("u")
|
|
|
|
screen:expect([[
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
"Xtest-overwrite" |
|
|
|
|
{2:WARNING: The file has been changed since reading it!!!} |
|
|
|
|
{3:Do you really want to write to it (y/n)?}u |
|
|
|
|
{3:Do you really want to write to it (y/n)?}^ |
|
|
|
|
]])
|
|
|
|
|
|
|
|
feed("\005")
|
|
|
|
screen:expect([[
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
"Xtest-overwrite" |
|
|
|
|
{2:WARNING: The file has been changed since reading it!!!} |
|
|
|
|
{3:Do you really want to write to it (y/n)?}u |
|
|
|
|
{3:Do you really want to write to it (y/n)?} |
|
|
|
|
{3:Do you really want to write to it (y/n)?}^ |
|
|
|
|
]])
|
|
|
|
|
|
|
|
feed("n")
|
|
|
|
screen:expect([[
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
"Xtest-overwrite" |
|
|
|
|
{2:WARNING: The file has been changed since reading it!!!} |
|
|
|
|
{3:Do you really want to write to it (y/n)?}u |
|
|
|
|
{3:Do you really want to write to it (y/n)?} |
|
|
|
|
{3:Do you really want to write to it (y/n)?}n |
|
|
|
|
{3:Press ENTER or type command to continue}^ |
|
|
|
|
]])
|
|
|
|
|
|
|
|
feed("<cr>")
|
|
|
|
screen:expect([[
|
|
|
|
^foobar |
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
2021-01-04 11:04:21 -07:00
|
|
|
|
|
|
|
describe("event processing and input", function()
|
|
|
|
it('not blocked by event bursts', function()
|
|
|
|
meths.set_keymap('', '<f2>', "<cmd>lua vim.rpcnotify(1, 'stop') winning = true <cr>", {noremap=true})
|
|
|
|
|
|
|
|
exec_lua [[
|
|
|
|
winning = false
|
|
|
|
burst = vim.schedule_wrap(function(tell)
|
|
|
|
if tell then
|
|
|
|
vim.rpcnotify(1, 'start')
|
|
|
|
end
|
|
|
|
-- Are we winning, son?
|
|
|
|
if not winning then
|
|
|
|
burst(false)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
burst(true)
|
|
|
|
]]
|
|
|
|
|
|
|
|
eq({'notification', 'start', {}}, next_msg())
|
|
|
|
feed '<f2>'
|
|
|
|
eq({'notification', 'stop', {}}, next_msg())
|
|
|
|
end)
|
|
|
|
end)
|
2022-03-29 14:25:00 -07:00
|
|
|
|
|
|
|
describe('display is updated', function()
|
|
|
|
local screen
|
|
|
|
before_each(function()
|
|
|
|
screen = Screen.new(60, 8)
|
|
|
|
screen:set_default_attr_ids({
|
|
|
|
[1] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText
|
|
|
|
[2] = {bold = true}, -- ModeMsg
|
|
|
|
})
|
|
|
|
screen:attach()
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('in Insert mode after <Nop> mapping #17911', function()
|
|
|
|
command('imap <Plug>test <Nop>')
|
|
|
|
command('imap <F2> abc<CR><Plug>test')
|
|
|
|
feed('i<F2>')
|
|
|
|
screen:expect([[
|
|
|
|
abc |
|
|
|
|
^ |
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{2:-- INSERT --} |
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('in Insert mode after empty string <expr> mapping #17911', function()
|
|
|
|
command('imap <expr> <Plug>test ""')
|
|
|
|
command('imap <F2> abc<CR><Plug>test')
|
|
|
|
feed('i<F2>')
|
|
|
|
screen:expect([[
|
|
|
|
abc |
|
|
|
|
^ |
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{1:~ }|
|
|
|
|
{2:-- INSERT --} |
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|