diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-07-25 10:15:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-25 10:15:44 +0800 |
commit | e9b58a619e1dd7a831138dc14bd8258104724e06 (patch) | |
tree | d757afdb3bc7ee8ea52ab1268feaeb60378fe3eb /test/functional/ui | |
parent | 46e3e1c7280a409462cceb520fe12259b5ba9937 (diff) | |
parent | 0cc41a61d1ac504bae4975021b95ce133268ce1a (diff) | |
download | rneovim-e9b58a619e1dd7a831138dc14bd8258104724e06.tar.gz rneovim-e9b58a619e1dd7a831138dc14bd8258104724e06.tar.bz2 rneovim-e9b58a619e1dd7a831138dc14bd8258104724e06.zip |
Merge pull request #18992 from zeertzjq/alt-mouse
fix(input): do no reinterpret mouse keys with ALT modifiers
Diffstat (limited to 'test/functional/ui')
-rw-r--r-- | test/functional/ui/mouse_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/ui/statusline_spec.lua | 48 |
2 files changed, 42 insertions, 18 deletions
diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index 7305bd589b..e389b7ab89 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -1572,23 +1572,17 @@ describe('ui/mouse/input', function() meths.input_mouse('left', 'release', '', 0, 0, 0) end) - it('scroll keys are not translated into multiclicks #6211 #6989', function() + it('scroll keys are not translated into multiclicks and can be mapped #6211 #6989', function() meths.set_var('mouse_up', 0) meths.set_var('mouse_up2', 0) - meths.set_var('mouse_up3', 0) - meths.set_var('mouse_up4', 0) command('nnoremap <ScrollWheelUp> <Cmd>let g:mouse_up += 1<CR>') command('nnoremap <2-ScrollWheelUp> <Cmd>let g:mouse_up2 += 1<CR>') - command('nnoremap <3-ScrollWheelUp> <Cmd>let g:mouse_up3 += 1<CR>') - command('nnoremap <4-ScrollWheelUp> <Cmd>let g:mouse_up4 += 1<CR>') - meths.input_mouse('wheel', 'up', '', 0, 0, 0) - meths.input_mouse('wheel', 'up', '', 0, 0, 0) + feed('<ScrollWheelUp><0,0>') + feed('<ScrollWheelUp><0,0>') meths.input_mouse('wheel', 'up', '', 0, 0, 0) meths.input_mouse('wheel', 'up', '', 0, 0, 0) eq(4, meths.get_var('mouse_up')) eq(0, meths.get_var('mouse_up2')) - eq(0, meths.get_var('mouse_up3')) - eq(0, meths.get_var('mouse_up4')) end) it('feeding <MouseMove> does not use uninitialized memory #19480', function() diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 760760150c..69a2d2f4ed 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -21,11 +21,9 @@ describe('statusline clicks', function() command('set laststatus=2 mousemodel=extend') exec([=[ function! MyClickFunc(minwid, clicks, button, mods) - let mods = trim(a:mods) - if mods ==# '' - let g:testvar = printf("%d %d %s", a:minwid, a:clicks, a:button) - else - let g:testvar = printf("%d %d %s %s", a:minwid, a:clicks, a:button, mods) + let g:testvar = printf("%d %d %s", a:minwid, a:clicks, a:button) + if a:mods !=# ' ' + let g:testvar ..= '(' .. a:mods .. ')' endif endfunction ]=]) @@ -35,8 +33,20 @@ describe('statusline clicks', function() meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') meths.input_mouse('left', 'press', '', 0, 6, 17) eq('0 1 l', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 6, 17) + eq('0 2 l', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 6, 17) + eq('0 3 l', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 6, 17) + eq('0 4 l', eval("g:testvar")) meths.input_mouse('right', 'press', '', 0, 6, 17) eq('0 1 r', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 17) + eq('0 2 r', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 17) + eq('0 3 r', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 17) + eq('0 4 r', eval("g:testvar")) end) it('works for winbar', function() @@ -101,10 +111,30 @@ describe('statusline clicks', function() it("works with modifiers #18994", function() meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') - meths.input_mouse('right', 'press', 's', 0, 6, 17) - eq('0 1 r s', eval("g:testvar")) - meths.input_mouse('left', 'press', 's', 0, 6, 17) - eq('0 1 l s', eval("g:testvar")) + -- Note: alternate between left and right mouse buttons to avoid triggering multiclicks + meths.input_mouse('left', 'press', 'S', 0, 6, 17) + eq('0 1 l(s )', eval("g:testvar")) + meths.input_mouse('right', 'press', 'S', 0, 6, 17) + eq('0 1 r(s )', eval("g:testvar")) + meths.input_mouse('left', 'press', 'A', 0, 6, 17) + eq('0 1 l( a )', eval("g:testvar")) + meths.input_mouse('right', 'press', 'A', 0, 6, 17) + eq('0 1 r( a )', eval("g:testvar")) + meths.input_mouse('left', 'press', 'AS', 0, 6, 17) + eq('0 1 l(s a )', eval("g:testvar")) + meths.input_mouse('right', 'press', 'AS', 0, 6, 17) + eq('0 1 r(s a )', eval("g:testvar")) + meths.input_mouse('left', 'press', 'T', 0, 6, 17) + eq('0 1 l( m)', eval("g:testvar")) + meths.input_mouse('right', 'press', 'T', 0, 6, 17) + eq('0 1 r( m)', eval("g:testvar")) + meths.input_mouse('left', 'press', 'TS', 0, 6, 17) + eq('0 1 l(s m)', eval("g:testvar")) + meths.input_mouse('right', 'press', 'TS', 0, 6, 17) + eq('0 1 r(s m)', eval("g:testvar")) + meths.input_mouse('left', 'press', 'C', 0, 6, 17) + eq('0 1 l( c )', eval("g:testvar")) + -- <C-RightMouse> is for tag jump end) it("works for global statusline with vertical splits #19186", function() |