fix(pum): make right drag in anchor grid to select work in multigrid UI (#19382)

This commit is contained in:
zeertzjq 2022-07-16 08:26:40 +08:00 committed by GitHub
parent 86f0da922f
commit 33da7d83e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 92 additions and 1 deletions

View File

@ -976,7 +976,7 @@ static void pum_select_mouse_pos(void)
if (mouse_grid == pum_grid.handle) { if (mouse_grid == pum_grid.handle) {
pum_selected = mouse_row; pum_selected = mouse_row;
return; return;
} else if (mouse_grid > 1) { } else if (mouse_grid != pum_anchor_grid) {
pum_selected = -1; pum_selected = -1;
return; return;
} }

View File

@ -2427,6 +2427,34 @@ describe('builtin popupmenu', function()
:let g:menustr = 'baz' | :let g:menustr = 'baz' |
]]) ]])
eq('baz', meths.get_var('menustr')) eq('baz', meths.get_var('menustr'))
meths.input_mouse('right', 'press', '', 0, 0, 4)
screen:expect([[
^popup menu test |
{1:~ }{n: foo }{1: }|
{1:~ }{n: bar }{1: }|
{1:~ }{n: baz }{1: }|
{1:~ }|
:let g:menustr = 'baz' |
]])
meths.input_mouse('right', 'drag', '', 0, 3, 6)
screen:expect([[
^popup menu test |
{1:~ }{n: foo }{1: }|
{1:~ }{n: bar }{1: }|
{1:~ }{s: baz }{1: }|
{1:~ }|
:let g:menustr = 'baz' |
]])
meths.input_mouse('right', 'release', '', 0, 1, 6)
screen:expect([[
^popup menu test |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
:let g:menustr = 'foo' |
]])
eq('foo', meths.get_var('menustr'))
end) end)
end) end)
@ -2571,5 +2599,68 @@ describe('builtin popupmenu with ui/ext_multigrid', function()
:let g:menustr = 'baz' | :let g:menustr = 'baz' |
]]}) ]]})
eq('baz', meths.get_var('menustr')) eq('baz', meths.get_var('menustr'))
meths.input_mouse('right', 'press', '', 2, 0, 4)
screen:expect({grid=[[
## grid 1
[2:--------------------------------]|
[2:--------------------------------]|
[2:--------------------------------]|
[2:--------------------------------]|
[2:--------------------------------]|
[3:--------------------------------]|
## grid 2
^popup menu test |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
:let g:menustr = 'baz' |
## grid 4
{n: foo }|
{n: bar }|
{n: baz }|
]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 100}}})
meths.input_mouse('right', 'drag', '', 2, 3, 6)
screen:expect({grid=[[
## grid 1
[2:--------------------------------]|
[2:--------------------------------]|
[2:--------------------------------]|
[2:--------------------------------]|
[2:--------------------------------]|
[3:--------------------------------]|
## grid 2
^popup menu test |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
:let g:menustr = 'baz' |
## grid 4
{n: foo }|
{n: bar }|
{s: baz }|
]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 100}}})
meths.input_mouse('right', 'release', '', 2, 1, 6)
screen:expect({grid=[[
## grid 1
[2:--------------------------------]|
[2:--------------------------------]|
[2:--------------------------------]|
[2:--------------------------------]|
[2:--------------------------------]|
[3:--------------------------------]|
## grid 2
^popup menu test |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
:let g:menustr = 'foo' |
]]})
eq('foo', meths.get_var('menustr'))
end) end)
end) end)