comparison src/testdir/test_mapping.vim @ 32369:ffbae151e462 v9.0.1516

patch 9.0.1516: cannot use special keys in <Cmd> mapping Commit: https://github.com/vim/vim/commit/3ab3a864814f903da8a158c01820e4fbe1013c08 Author: zeertzjq <zeertzjq@outlook.com> Date: Sat May 6 16:22:04 2023 +0100 patch 9.0.1516: cannot use special keys in <Cmd> mapping Problem: Cannot use special keys in <Cmd> mapping. Solution: Do allow for special keys in <Cmd> and <ScriptCmd> mappings. (closes #12326)
author Bram Moolenaar <Bram@vim.org>
date Sat, 06 May 2023 17:30:03 +0200
parents f99b85fc18e7
children 448aef880252
comparison
equal deleted inserted replaced
32368:2992e4adb0da 32369:ffbae151e462
999 let x = 0 999 let x = 0
1000 noremap <F3> <Cmd><Cmd>let x = 1<CR> 1000 noremap <F3> <Cmd><Cmd>let x = 1<CR>
1001 call assert_fails('call feedkeys("\<F3>", "xt")', 'E1136:') 1001 call assert_fails('call feedkeys("\<F3>", "xt")', 'E1136:')
1002 call assert_equal(0, x) 1002 call assert_equal(0, x)
1003 1003
1004 noremap <F3> <Cmd><F3>let x = 2<CR>
1005 call assert_fails('call feedkeys("\<F3>", "xt")', 'E1137:')
1006 call assert_equal(0, x)
1007
1008 noremap <F3> <Cmd>let x = 3 1004 noremap <F3> <Cmd>let x = 3
1009 call assert_fails('call feedkeys("\<F3>", "xt!")', 'E1255:') 1005 call assert_fails('call feedkeys("\<F3>", "xt!")', 'E1255:')
1010 call assert_equal(0, x) 1006 call assert_equal(0, x)
1011 1007
1012 " works in various modes and sees the correct mode() 1008 " works in various modes and sees the correct mode()
1102 call assert_equal(32, g:x) 1098 call assert_equal(32, g:x)
1103 1099
1104 unmap <F3> 1100 unmap <F3>
1105 unmap! <F3> 1101 unmap! <F3>
1106 %bw! 1102 %bw!
1107
1108 " command line ending in "0" is handled without errors
1109 onoremap ix <cmd>eval 0<cr>
1110 call feedkeys('dix.', 'xt')
1111 ounmap ix
1112 endfunc 1103 endfunc
1113 1104
1114 " text object enters visual mode 1105 " text object enters visual mode
1115 func TextObj() 1106 func TextObj()
1116 if mode() !=# "v" 1107 if mode() !=# "v"
1493 1484
1494 bwipe! 1485 bwipe!
1495 call delete('Xcmdtext') 1486 call delete('Xcmdtext')
1496 delfunc SelectDash 1487 delfunc SelectDash
1497 ounmap i- 1488 ounmap i-
1489
1490 new
1491 call setline(1, 'aaa bbb ccc ddd')
1492
1493 " command can contain special keys
1494 onoremap ix <Cmd>let g:foo ..= '…'<Bar>normal! <C-Right><CR>
1495 let g:foo = ''
1496 call feedkeys('0dix.', 'xt')
1497 call assert_equal('……', g:foo)
1498 call assert_equal('ccc ddd', getline(1))
1499 unlet g:foo
1500
1501 " command line ending in "0" is handled without errors
1502 onoremap ix <Cmd>eval 0<CR>
1503 call feedkeys('dix.', 'xt')
1504
1505 ounmap ix
1506 bwipe!
1498 endfunc 1507 endfunc
1499 1508
1500 func Test_map_script_cmd_restore() 1509 func Test_map_script_cmd_restore()
1501 let lines =<< trim END 1510 let lines =<< trim END
1502 vim9script 1511 vim9script