aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/terminal/buffer_spec.lua92
-rw-r--r--test/old/testdir/test_functions.vim71
2 files changed, 84 insertions, 79 deletions
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua
index d36dc60a93..4635259e33 100644
--- a/test/functional/terminal/buffer_spec.lua
+++ b/test/functional/terminal/buffer_spec.lua
@@ -557,7 +557,7 @@ describe('terminal input', function()
'--cmd',
'set notermguicolors',
'-c',
- 'while 1 | redraw | echo keytrans(getcharstr()) | endwhile',
+ 'while 1 | redraw | echo keytrans(getcharstr(-1, #{simplify: 0})) | endwhile',
})
screen:expect([[
^ |
@@ -566,7 +566,10 @@ describe('terminal input', function()
|
{3:-- TERMINAL --} |
]])
- for _, key in ipairs({
+ local keys = {
+ '<Tab>',
+ '<CR>',
+ '<Esc>',
'<M-Tab>',
'<M-CR>',
'<M-Esc>',
@@ -632,7 +635,14 @@ describe('terminal input', function()
'<S-ScrollWheelRight>',
'<ScrollWheelLeft>',
'<ScrollWheelRight>',
- }) do
+ }
+ -- FIXME: The escape sequence to enable kitty keyboard mode doesn't work on Windows
+ if not is_os('win') then
+ table.insert(keys, '<C-I>')
+ table.insert(keys, '<C-M>')
+ table.insert(keys, '<C-[>')
+ end
+ for _, key in ipairs(keys) do
feed(key)
screen:expect(([[
|
@@ -643,82 +653,6 @@ describe('terminal input', function()
]]):format(key:gsub('<%d+,%d+>$', '')))
end
end)
-
- -- TODO(bfredl): getcharstr() erases the distinction between <C-I> and <Tab>.
- -- If it was enhanced or replaced this could get folded into the test above.
- it('can send TAB/C-I and ESC/C-[ separately', function()
- if
- skip(
- is_os('win'),
- "The escape sequence to enable kitty keyboard mode doesn't work on Windows"
- )
- then
- return
- end
- clear()
- local screen = tt.setup_child_nvim({
- '-u',
- 'NONE',
- '-i',
- 'NONE',
- '--cmd',
- 'colorscheme vim',
- '--cmd',
- 'set notermguicolors',
- '--cmd',
- 'noremap <Tab> <cmd>echo "Tab!"<cr>',
- '--cmd',
- 'noremap <C-i> <cmd>echo "Ctrl-I!"<cr>',
- '--cmd',
- 'noremap <Esc> <cmd>echo "Esc!"<cr>',
- '--cmd',
- 'noremap <C-[> <cmd>echo "Ctrl-[!"<cr>',
- })
-
- screen:expect([[
- ^ |
- {4:~ }|*3
- {5:[No Name] 0,0-1 All}|
- |
- {3:-- TERMINAL --} |
- ]])
-
- feed('<tab>')
- screen:expect([[
- ^ |
- {4:~ }|*3
- {5:[No Name] 0,0-1 All}|
- Tab! |
- {3:-- TERMINAL --} |
- ]])
-
- feed('<c-i>')
- screen:expect([[
- ^ |
- {4:~ }|*3
- {5:[No Name] 0,0-1 All}|
- Ctrl-I! |
- {3:-- TERMINAL --} |
- ]])
-
- feed('<Esc>')
- screen:expect([[
- ^ |
- {4:~ }|*3
- {5:[No Name] 0,0-1 All}|
- Esc! |
- {3:-- TERMINAL --} |
- ]])
-
- feed('<c-[>')
- screen:expect([[
- ^ |
- {4:~ }|*3
- {5:[No Name] 0,0-1 All}|
- Ctrl-[! |
- {3:-- TERMINAL --} |
- ]])
- end)
end)
if is_os('win') then
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