diff options
author | zeertzjq <zeertzjq@outlook.com> | 2025-02-02 17:32:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-02 09:32:51 +0000 |
commit | 4bdabf9b1ae52134f50a0b75dc2c73a40c0c252f (patch) | |
tree | 1d57e428e413301df6a6d4c4cdbf7ff7853c8e7c /test/old | |
parent | 718e9ce018572f609a7639865af55476a19847aa (diff) | |
download | rneovim-4bdabf9b1ae52134f50a0b75dc2c73a40c0c252f.tar.gz rneovim-4bdabf9b1ae52134f50a0b75dc2c73a40c0c252f.tar.bz2 rneovim-4bdabf9b1ae52134f50a0b75dc2c73a40c0c252f.zip |
vim-patch:9.1.1068: getchar() can't distinguish between C-I and Tab (#32295)
Problem: getchar() can't distinguish between C-I and Tab.
Solution: Add {opts} to pass extra flags to getchar() and getcharstr(),
with "number" and "simplify" keys.
related: vim/vim#10603
closes: vim/vim#16554
https://github.com/vim/vim/commit/e0a2ab397fd13a71efec85b017d5d4d62baf7f63
Cherry-pick tv_dict_has_key() from patch 8.2.4683.
Diffstat (limited to 'test/old')
-rw-r--r-- | test/old/testdir/test_functions.vim | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim index 01e6001dcc..f57743900a 100644 --- a/test/old/testdir/test_functions.vim +++ b/test/old/testdir/test_functions.vim @@ -2390,6 +2390,77 @@ func Test_getchar() call assert_equal("\<M-F2>", getchar(0)) call assert_equal(0, getchar(0)) + call feedkeys("\<Tab>", '') + call assert_equal(char2nr("\<Tab>"), getchar()) + call feedkeys("\<Tab>", '') + call assert_equal(char2nr("\<Tab>"), getchar(-1)) + call feedkeys("\<Tab>", '') + call assert_equal(char2nr("\<Tab>"), getchar(-1, {})) + call feedkeys("\<Tab>", '') + call assert_equal(char2nr("\<Tab>"), getchar(-1, #{number: v:true})) + call assert_equal(0, getchar(0)) + call assert_equal(0, getchar(1)) + call assert_equal(0, getchar(0, #{number: v:true})) + call assert_equal(0, getchar(1, #{number: v:true})) + + call feedkeys("\<Tab>", '') + call assert_equal("\<Tab>", getcharstr()) + call feedkeys("\<Tab>", '') + call assert_equal("\<Tab>", getcharstr(-1)) + call feedkeys("\<Tab>", '') + call assert_equal("\<Tab>", getcharstr(-1, {})) + call feedkeys("\<Tab>", '') + call assert_equal("\<Tab>", getchar(-1, #{number: v:false})) + call assert_equal('', getcharstr(0)) + call assert_equal('', getcharstr(1)) + call assert_equal('', getchar(0, #{number: v:false})) + call assert_equal('', getchar(1, #{number: v:false})) + + " Nvim: <M-x> is never simplified + " for key in ["C-I", "C-X", "M-x"] + for key in ["C-I", "C-X"] + let lines =<< eval trim END + call feedkeys("\<*{key}>", '') + call assert_equal(char2nr("\<{key}>"), getchar()) + call feedkeys("\<*{key}>", '') + call assert_equal(char2nr("\<{key}>"), getchar(-1)) + call feedkeys("\<*{key}>", '') + call assert_equal(char2nr("\<{key}>"), getchar(-1, {{}})) + call feedkeys("\<*{key}>", '') + call assert_equal(char2nr("\<{key}>"), getchar(-1, {{'number': 1}})) + call feedkeys("\<*{key}>", '') + call assert_equal(char2nr("\<{key}>"), getchar(-1, {{'simplify': 1}})) + call feedkeys("\<*{key}>", '') + call assert_equal("\<*{key}>", getchar(-1, {{'simplify': v:false}})) + call assert_equal(0, getchar(0)) + call assert_equal(0, getchar(1)) + END + call CheckLegacyAndVim9Success(lines) + + let lines =<< eval trim END + call feedkeys("\<*{key}>", '') + call assert_equal("\<{key}>", getcharstr()) + call feedkeys("\<*{key}>", '') + call assert_equal("\<{key}>", getcharstr(-1)) + call feedkeys("\<*{key}>", '') + call assert_equal("\<{key}>", getcharstr(-1, {{}})) + call feedkeys("\<*{key}>", '') + call assert_equal("\<{key}>", getchar(-1, {{'number': 0}})) + call feedkeys("\<*{key}>", '') + call assert_equal("\<{key}>", getcharstr(-1, {{'simplify': 1}})) + call feedkeys("\<*{key}>", '') + call assert_equal("\<*{key}>", getcharstr(-1, {{'simplify': v:false}})) + call assert_equal('', getcharstr(0)) + call assert_equal('', getcharstr(1)) + END + call CheckLegacyAndVim9Success(lines) + endfor + + call assert_fails('call getchar(1, 1)', 'E1206:') + call assert_fails('call getcharstr(1, 1)', 'E1206:') + call assert_fails('call getcharstr(1, #{number: v:true})', 'E475:') + call assert_fails('call getcharstr(1, #{number: v:false})', 'E475:') + call setline(1, 'xxxx') call Ntest_setmouse(1, 3) let v:mouse_win = 9 |