From 818456470c0ce0d463b0be82e9c35eb77cc65f19 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 23 Jan 2022 05:58:32 +0800 Subject: fix(input): put modifiers back into typeahead buffer when needed --- test/functional/terminal/mouse_spec.lua | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua index 780a0b9b5a..6e2c851df7 100644 --- a/test/functional/terminal/mouse_spec.lua +++ b/test/functional/terminal/mouse_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local clear, eq, eval = helpers.clear, helpers.eq, helpers.eval -local feed, nvim = helpers.feed, helpers.nvim +local feed, nvim, command = helpers.feed, helpers.nvim, helpers.command local feed_data = thelpers.feed_data describe(':terminal mouse', function() @@ -10,9 +10,9 @@ describe(':terminal mouse', function() before_each(function() clear() nvim('set_option', 'statusline', '==========') - nvim('command', 'highlight StatusLine cterm=NONE') - nvim('command', 'highlight StatusLineNC cterm=NONE') - nvim('command', 'highlight VertSplit cterm=NONE') + command('highlight StatusLine cterm=NONE') + command('highlight StatusLineNC cterm=NONE') + command('highlight VertSplit cterm=NONE') screen = thelpers.screen_setup() local lines = {} for i = 1, 30 do @@ -38,6 +38,26 @@ describe(':terminal mouse', function() eq('nt', eval('mode(1)')) end) + it('will exit focus and trigger Normal mode mapping on mouse click', function() + command('let g:got_leftmouse = 0') + command('nnoremap let g:got_leftmouse = 1') + eq('t', eval('mode(1)')) + eq(0, eval('g:got_leftmouse')) + feed('') + eq('nt', eval('mode(1)')) + eq(1, eval('g:got_leftmouse')) + end) + + it('will exit focus and trigger Normal mode mapping on mouse click with modifier', function() + command('let g:got_ctrl_leftmouse = 0') + command('nnoremap let g:got_ctrl_leftmouse = 1') + eq('t', eval('mode(1)')) + eq(0, eval('g:got_ctrl_leftmouse')) + feed('') + eq('nt', eval('mode(1)')) + eq(1, eval('g:got_ctrl_leftmouse')) + end) + it('will exit focus on + mouse-scroll', function() eq('t', eval('mode(1)')) feed('') @@ -180,7 +200,7 @@ describe(':terminal mouse', function() it('will forward mouse clicks to the program with the correct even if set nu', function() if helpers.pending_win32(pending) then return end - nvim('command', 'set number') + command('set number') -- When the display area such as a number is clicked, it returns to the -- normal mode. feed('<3,0>') -- cgit From 0efe1ec6b3a869cdfceb2ab98b230b52374a17ae Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 23 Jan 2022 05:58:32 +0800 Subject: test(input): add more tests for K_SPECIAL escaping in ins_char_typebuf() --- test/functional/editor/meta_key_spec.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/functional/editor/meta_key_spec.lua b/test/functional/editor/meta_key_spec.lua index 2280f5bb24..f811b8ae8d 100644 --- a/test/functional/editor/meta_key_spec.lua +++ b/test/functional/editor/meta_key_spec.lua @@ -27,6 +27,14 @@ describe('meta-keys #8226 #13042', function() command('nnoremap Aalt-j') feed('') expect('llo;;alt-jmeta-l') + -- Unmapped ALT-chord with characters containing K_SPECIAL bytes + command('nnoremap … A…') + feed('') + expect('llo;;alt-jmeta-l…') + command("execute 'nnoremap' nr2char(0x40000000) 'AMAX'") + command("call nvim_input('')") + command("call nvim_input('')") + expect('llo;;alt-jmeta-lMAXMAX') end) it('ALT/META, visual-mode', function() @@ -36,13 +44,20 @@ describe('meta-keys #8226 #13042', function() expect('peach') -- Unmapped ALT-chord resolves isolated (non-ALT) ESC mapping. #13086 #15869 command('vnoremap AESC>') - feed('viwviw') + feed('viwviw') expect('peach;;') -- Mapped ALT-chord behaves as mapped. command('vnoremap Ameta-l') command('vnoremap Aalt-j') feed('viwviw') expect('peach;;alt-jmeta-l') + -- Unmapped ALT-chord with characters containing K_SPECIAL bytes + feed('viwviw') + expect('peach;;alt-jmeta-l…') + command("execute 'inoremap' nr2char(0x40000000) 'MAX'") + command("call nvim_input('viw')") + command("call nvim_input('viw')") + expect('peach;;alt-jmeta-lMAXMAX') end) it('ALT/META insert-mode', function() -- cgit