fix(pum): don't position too far with resized parent grid (#23442)

This commit is contained in:
zeertzjq
2023-05-03 06:17:53 +08:00
committed by GitHub
parent 3ba930844c
commit 540941ef83
2 changed files with 449 additions and 66 deletions

View File

@@ -40,6 +40,7 @@ describe('ext_multigrid', function()
[21] = {background = Screen.colors.LightMagenta},
[22] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue},
[23] = {background = Screen.colors.Grey90},
[24] = {background = Screen.colors.Grey},
})
end)
@@ -1292,6 +1293,154 @@ describe('ext_multigrid', function()
[4] = {{id = 1001}, "SE", 2, 16, 58, true, 50};
}}
end)
it('completion popup position', function()
insert(('\n'):rep(14) .. ('foo bar '):rep(7))
feed('A<C-X><C-N>')
screen:expect{grid=[[
## grid 1
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
{11:[No Name] [+] }|
[3:-----------------------------------------------------]|
## grid 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo^ |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
{7:-- Keyword Local completion (^N^P) }{15:match 1 of 2} |
## grid 4
{24: foo}|
{21: bar}|
]], float_pos={
[4] = {{id = -1}, "NW", 2, 15, 55, false, 100};
}}
feed('<C-E><Esc>')
command('setlocal rightleft')
feed('o<C-X><C-N>')
screen:expect{grid=[[
## grid 1
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
{11:[No Name] [+] }|
[3:-----------------------------------------------------]|
## grid 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rab oof rab oof rab oof rab oof rab oof rab oof rab oof|
^ oof|
{1: ~}|
{1: ~}|
{1: ~}|
{1: ~}|
## grid 3
{7:-- Keyword Local completion (^N^P) }{15:match 1 of 2} |
## grid 4
{24: oof}|
{21: rab}|
]], float_pos={
[4] = {{id = -1}, "NW", 2, 16, 45, false, 100};
}}
feed('<C-E><Esc>')
command('set wildoptions+=pum')
feed(':sign un<Tab>')
screen:expect{grid=[[
## grid 1
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
{11:[No Name] [+] }|
[3:-----------------------------------------------------]|
## grid 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rab oof rab oof rab oof rab oof rab oof rab oof rab oof|
|
{1: ~}|
{1: ~}|
{1: ~}|
{1: ~}|
## grid 3
:sign undefine^ |
## grid 4
{24: undefine }|
{21: unplace }|
]], float_pos={
[4] = {{id = -1}, "SW", 1, 13, 5, false, 250};
}}
end)
end)
it('multiline messages scroll over windows', function()
@@ -2446,8 +2595,48 @@ describe('ext_multigrid', function()
]]}
meths.input_mouse('right', 'press', '', 4, 0, 64)
meths.input_mouse('right', 'release', '', 4, 0, 64)
-- FIXME: popup menu position is strange
-- screen:expect{}
screen:expect{grid=[[
## grid 1
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
{11:[No Name] [+] }|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
{12:[No Name] [+] [No Name] [+] }|
[3:-----------------------------------------------------]|
## grid 2
some text |
to be clicked |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
{7:-- VISUAL --} |
## grid 4
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do {20:eiusm}^o |
{1:~ }|
## grid 5
some text |
to be clicked |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 6
{21: Copy }|
]], float_pos={
[6] = {{id = -1}, "NW", 4, 1, 63, false, 250};
}}
feed('<Down><CR>')
screen:expect{grid=[[
## grid 1
@@ -2670,6 +2859,191 @@ describe('ext_multigrid', function()
{1:~ }|
]]}
eq('eiusmo', funcs.getreg('"'))
screen:try_resize_grid(4, 7, 11)
screen:expect{grid=[[
## grid 1
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
{12:[No Name] [+] [No Name] [+] }|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
{11:[No Name] [+] }|
[3:-----------------------------------------------------]|
## grid 2
some text |
to be clicked |
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
|
## grid 4
^Lorem i|
psum do|
lor sit|
amet, |
consect|
etur ad|
ipiscin|
g elit,|
sed do|
eiusmo|
{1:~ }|
## grid 5
some text |
to be clicked |
{1:~ }|
{1:~ }|
{1:~ }|
]]}
funcs.setreg('"', '')
meths.input_mouse('left', 'press', '2', 4, 9, 1)
screen:expect{grid=[[
## grid 1
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
{12:[No Name] [+] [No Name] [+] }|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
{11:[No Name] [+] }|
[3:-----------------------------------------------------]|
## grid 2
some text |
to be clicked |
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
{7:-- VISUAL --} |
## grid 4
Lorem i|
psum do|
lor sit|
amet, |
consect|
etur ad|
ipiscin|
g elit,|
sed do|
{20:eiusm}^o|
{1:~ }|
## grid 5
some text |
to be clicked |
{1:~ }|
{1:~ }|
{1:~ }|
]]}
meths.input_mouse('right', 'press', '', 4, 9, 1)
meths.input_mouse('right', 'release', '', 4, 9, 1)
screen:expect{grid=[[
## grid 1
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
{12:[No Name] [+] [No Name] [+] }|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
{11:[No Name] [+] }|
[3:-----------------------------------------------------]|
## grid 2
some text |
to be clicked |
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
{7:-- VISUAL --} |
## grid 4
Lorem i|
psum do|
lor sit|
amet, |
consect|
etur ad|
ipiscin|
g elit,|
sed do|
{20:eiusm}^o|
{1:~ }|
## grid 5
some text |
to be clicked |
{1:~ }|
{1:~ }|
{1:~ }|
## grid 6
{21: Copy }|
]], float_pos={
[6] = {{id = -1}, "NW", 4, 10, 0, false, 250};
}}
feed('<Down><CR>')
screen:expect{grid=[[
## grid 1
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
[5:------------------------------]│[2:----------------------]|
{12:[No Name] [+] [No Name] [+] }|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
{11:[No Name] [+] }|
[3:-----------------------------------------------------]|
## grid 2
some text |
to be clicked |
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
|
## grid 4
Lorem i|
psum do|
lor sit|
amet, |
consect|
etur ad|
ipiscin|
g elit,|
sed do|
^eiusmo|
{1:~ }|
## grid 5
some text |
to be clicked |
{1:~ }|
{1:~ }|
{1:~ }|
]]}
eq('eiusmo', funcs.getreg('"'))
end)
it('supports mouse drag with mouse=a', function()