mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #23352 from zeertzjq/pum-at-cursor
fix(pum): make :popup position correctly with float border
This commit is contained in:
commit
50107c3778
@ -1169,8 +1169,15 @@ void pum_make_popup(const char *path_name, int use_mouse_pos)
|
|||||||
if (!use_mouse_pos) {
|
if (!use_mouse_pos) {
|
||||||
// Hack: set mouse position at the cursor so that the menu pops up
|
// Hack: set mouse position at the cursor so that the menu pops up
|
||||||
// around there.
|
// around there.
|
||||||
mouse_row = curwin->w_winrow + curwin->w_wrow;
|
mouse_row = curwin->w_grid.row_offset + curwin->w_wrow;
|
||||||
mouse_col = curwin->w_wincol + curwin->w_wcol;
|
mouse_col = curwin->w_grid.col_offset + curwin->w_wcol;
|
||||||
|
if (ui_has(kUIMultigrid)) {
|
||||||
|
mouse_grid = curwin->w_grid.target->handle;
|
||||||
|
} else if (curwin->w_grid.target != &default_grid) {
|
||||||
|
mouse_grid = 0;
|
||||||
|
mouse_row += curwin->w_winrow;
|
||||||
|
mouse_col += curwin->w_wincol;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vimmenu_T *menu = menu_find(path_name);
|
vimmenu_T *menu = menu_find(path_name);
|
||||||
|
@ -9,6 +9,7 @@ local eval = helpers.eval
|
|||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local neq = helpers.neq
|
local neq = helpers.neq
|
||||||
local expect = helpers.expect
|
local expect = helpers.expect
|
||||||
|
local exec = helpers.exec
|
||||||
local exec_lua = helpers.exec_lua
|
local exec_lua = helpers.exec_lua
|
||||||
local insert = helpers.insert
|
local insert = helpers.insert
|
||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
@ -2123,7 +2124,7 @@ describe('float window', function()
|
|||||||
{5:║}{1:^ }{5:║}|
|
{5:║}{1:^ }{5:║}|
|
||||||
{5:╚═════════╝}|
|
{5:╚═════════╝}|
|
||||||
]], float_pos={
|
]], float_pos={
|
||||||
[5] = { { id = 1002 }, "NW", 1, 0, 5, true }
|
[5] = { { id = 1002 }, "NW", 1, 0, 5, true };
|
||||||
}, win_viewport={
|
}, win_viewport={
|
||||||
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
|
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
|
||||||
[5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 0, linecount = 3, sum_scroll_delta = 0};
|
[5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 0, linecount = 3, sum_scroll_delta = 0};
|
||||||
@ -2181,8 +2182,8 @@ describe('float window', function()
|
|||||||
{1: abb }|
|
{1: abb }|
|
||||||
{13: acc }|
|
{13: acc }|
|
||||||
]], float_pos={
|
]], float_pos={
|
||||||
[5] = { { id = 1002 }, "NW", 1, 0, 5, true, 50 },
|
[5] = { { id = 1002 }, "NW", 1, 0, 5, true, 50 };
|
||||||
[6] = { { id = -1 }, "NW", 5, 4, 0, false, 100 }
|
[6] = { { id = -1 }, "NW", 5, 4, 0, false, 100 };
|
||||||
}, win_viewport={
|
}, win_viewport={
|
||||||
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0};
|
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0};
|
||||||
[5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 3, linecount=3, sum_scroll_delta = 0};
|
[5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 3, linecount=3, sum_scroll_delta = 0};
|
||||||
@ -2201,6 +2202,122 @@ describe('float window', function()
|
|||||||
{3:-- }{8:match 1 of 4} |
|
{3:-- }{8:match 1 of 4} |
|
||||||
]]}
|
]]}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feed '<esc>'
|
||||||
|
if multigrid then
|
||||||
|
screen:expect{grid=[[
|
||||||
|
## grid 1
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[3:----------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
## grid 3
|
||||||
|
|
|
||||||
|
## grid 5
|
||||||
|
{5:╔═════════╗}|
|
||||||
|
{5:║}{1:aaa aab }{5:║}|
|
||||||
|
{5:║}{1:abb acc }{5:║}|
|
||||||
|
{5:║}{1:ac^c }{5:║}|
|
||||||
|
{5:╚═════════╝}|
|
||||||
|
]], float_pos={
|
||||||
|
[5] = { { id = 1002 }, "NW", 1, 0, 5, true };
|
||||||
|
}, win_viewport={
|
||||||
|
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
|
||||||
|
[5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 2, linecount = 3, sum_scroll_delta = 0};
|
||||||
|
}}
|
||||||
|
else
|
||||||
|
screen:expect{grid=[[
|
||||||
|
{5:╔═════════╗} |
|
||||||
|
{0:~ }{5:║}{1:aaa aab }{5:║}{0: }|
|
||||||
|
{0:~ }{5:║}{1:abb acc }{5:║}{0: }|
|
||||||
|
{0:~ }{5:║}{1:ac^c }{5:║}{0: }|
|
||||||
|
{0:~ }{5:╚═════════╝}{0: }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]]}
|
||||||
|
end
|
||||||
|
|
||||||
|
exec([[
|
||||||
|
nnoremenu Test.foo :
|
||||||
|
nnoremenu Test.bar :
|
||||||
|
nnoremenu Test.baz :
|
||||||
|
]])
|
||||||
|
feed ':popup Test<CR>'
|
||||||
|
if multigrid then
|
||||||
|
screen:expect{grid=[[
|
||||||
|
## grid 1
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[3:----------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
## grid 3
|
||||||
|
:popup Test |
|
||||||
|
## grid 5
|
||||||
|
{5:╔═════════╗}|
|
||||||
|
{5:║}{1:aaa aab }{5:║}|
|
||||||
|
{5:║}{1:abb acc }{5:║}|
|
||||||
|
{5:║}{1:ac^c }{5:║}|
|
||||||
|
{5:╚═════════╝}|
|
||||||
|
## grid 6
|
||||||
|
{1: foo }|
|
||||||
|
{1: bar }|
|
||||||
|
{1: baz }|
|
||||||
|
]], float_pos={
|
||||||
|
[5] = { { id = 1002 }, "NW", 1, 0, 5, true };
|
||||||
|
[6] = { { id = -1 }, "NW", 5, 4, 2, false, 250 };
|
||||||
|
}, win_viewport={
|
||||||
|
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
|
||||||
|
[5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 2, linecount = 3, sum_scroll_delta = 0};
|
||||||
|
}}
|
||||||
|
else
|
||||||
|
screen:expect{grid=[[
|
||||||
|
{5:╔═════════╗} |
|
||||||
|
{0:~ }{5:║}{1:aaa aab }{5:║}{0: }|
|
||||||
|
{0:~ }{5:║}{1:abb acc }{5:║}{0: }|
|
||||||
|
{0:~ }{5:║}{1:ac^c }{5:║}{0: }|
|
||||||
|
{0:~ }{5:╚═}{1: foo }{5:═══╝}{0: }|
|
||||||
|
{0:~ }{1: bar }{0: }|
|
||||||
|
{0:~ }{1: baz }{0: }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
:popup Test |
|
||||||
|
]]}
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('show ruler of current floating window', function()
|
it('show ruler of current floating window', function()
|
||||||
|
@ -4508,6 +4508,34 @@ describe('builtin popupmenu', function()
|
|||||||
{1:~ }|
|
{1:~ }|
|
||||||
pasted |
|
pasted |
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
-- Add a window toolbar to the window and check the :popup menu position.
|
||||||
|
command('setlocal winbar=TEST')
|
||||||
|
feed('/X<CR>:popup PopUp<CR>')
|
||||||
|
screen:expect([[
|
||||||
|
{2:TEST }|
|
||||||
|
one two three four five |
|
||||||
|
and one two {7:^X}three four five |
|
||||||
|
one more tw{n: Undo } |
|
||||||
|
{1:~ }{n: }{1: }|
|
||||||
|
{1:~ }{n: Paste }{1: }|
|
||||||
|
{1:~ }{n: }{1: }|
|
||||||
|
{1:~ }{n: Select Word }{1: }|
|
||||||
|
{1:~ }{n: Select Sentence }{1: }|
|
||||||
|
{1:~ }{n: Select Paragraph }{1: }|
|
||||||
|
{1:~ }{n: Select Line }{1: }|
|
||||||
|
{1:~ }{n: Select Block }{1: }|
|
||||||
|
{1:~ }{n: Select All }{1: }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
:popup PopUp |
|
||||||
|
]])
|
||||||
|
|
||||||
|
feed('<Esc>')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('"kind" and "menu"', function()
|
describe('"kind" and "menu"', function()
|
||||||
|
@ -885,14 +885,14 @@ func Test_popup_command_dump()
|
|||||||
echomsg 'changed'
|
echomsg 'changed'
|
||||||
endfunc
|
endfunc
|
||||||
END
|
END
|
||||||
call writefile(script, 'XtimerScript')
|
call writefile(script, 'XtimerScript', 'D')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
one two three four five
|
one two three four five
|
||||||
and one two Xthree four five
|
and one two Xthree four five
|
||||||
one more two three four five
|
one more two three four five
|
||||||
END
|
END
|
||||||
call writefile(lines, 'Xtest')
|
call writefile(lines, 'Xtest', 'D')
|
||||||
let buf = RunVimInTerminal('-S XtimerScript Xtest', {})
|
let buf = RunVimInTerminal('-S XtimerScript Xtest', {})
|
||||||
call term_sendkeys(buf, ":source $VIMRUNTIME/menu.vim\<CR>")
|
call term_sendkeys(buf, ":source $VIMRUNTIME/menu.vim\<CR>")
|
||||||
call term_sendkeys(buf, "/X\<CR>:popup PopUp\<CR>")
|
call term_sendkeys(buf, "/X\<CR>:popup PopUp\<CR>")
|
||||||
@ -910,7 +910,7 @@ func Test_popup_command_dump()
|
|||||||
|
|
||||||
" Set a timer to change a menu entry while it's displayed. The text should
|
" Set a timer to change a menu entry while it's displayed. The text should
|
||||||
" not change but the command does. Making the screendump also verifies that
|
" not change but the command does. Making the screendump also verifies that
|
||||||
" "changed" shows up, which means the timer triggered
|
" "changed" shows up, which means the timer triggered.
|
||||||
call term_sendkeys(buf, "/X\<CR>:call StartTimer() | popup PopUp\<CR>")
|
call term_sendkeys(buf, "/X\<CR>:call StartTimer() | popup PopUp\<CR>")
|
||||||
call VerifyScreenDump(buf, 'Test_popup_command_04', {})
|
call VerifyScreenDump(buf, 'Test_popup_command_04', {})
|
||||||
|
|
||||||
@ -918,9 +918,16 @@ func Test_popup_command_dump()
|
|||||||
call term_sendkeys(buf, "jj\<CR>")
|
call term_sendkeys(buf, "jj\<CR>")
|
||||||
call VerifyScreenDump(buf, 'Test_popup_command_05', {})
|
call VerifyScreenDump(buf, 'Test_popup_command_05', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "\<Esc>")
|
||||||
|
|
||||||
|
" Add a window toolbar to the window and check the :popup menu position.
|
||||||
|
call term_sendkeys(buf, ":nnoremenu WinBar.TEST :\<CR>")
|
||||||
|
call term_sendkeys(buf, "/X\<CR>:popup PopUp\<CR>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_popup_command_06', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "\<Esc>")
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
call delete('Xtest')
|
|
||||||
call delete('XtimerScript')
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_popup_complete_backwards()
|
func Test_popup_complete_backwards()
|
||||||
|
Loading…
Reference in New Issue
Block a user