mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
ui_compositior: handle multiple displayed floats in the same tick
problem: the order of non-focuesed float opened before focused float is wrong (sunjon) solution: check curwin and correct the order (bfredl)
This commit is contained in:
parent
bb7d3790bf
commit
eeb1099bc4
@ -180,7 +180,8 @@ bool ui_comp_put_grid(ScreenGrid *grid, int row, int col, int height, int width,
|
||||
if (kv_A(layers, insert_at-1) == &pum_grid && (grid != &msg_grid)) {
|
||||
insert_at--;
|
||||
}
|
||||
if (insert_at > 1 && !on_top) {
|
||||
if (curwin && kv_A(layers, insert_at-1) == &curwin->w_grid_alloc
|
||||
&& !on_top) {
|
||||
insert_at--;
|
||||
}
|
||||
// not found: new grid
|
||||
|
@ -772,9 +772,8 @@ void ui_ext_win_position(win_T *wp)
|
||||
wp->w_winrow = comp_row;
|
||||
wp->w_wincol = comp_col;
|
||||
bool valid = (wp->w_redr_type == 0);
|
||||
bool on_top = (curwin == wp) || !curwin->w_floating;
|
||||
ui_comp_put_grid(&wp->w_grid_alloc, comp_row, comp_col,
|
||||
wp->w_height_outer, wp->w_width_outer, valid, on_top);
|
||||
wp->w_height_outer, wp->w_width_outer, valid, false);
|
||||
ui_check_cursor_grid(wp->w_grid_alloc.handle);
|
||||
wp->w_grid_alloc.focusable = wp->w_float_config.focusable;
|
||||
if (!valid) {
|
||||
|
@ -6017,6 +6017,216 @@ describe('float window', function()
|
||||
]])
|
||||
end
|
||||
end)
|
||||
|
||||
it("correctly orders multiple opened floats (current last)", function()
|
||||
local buf = meths.create_buf(false,false)
|
||||
local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
|
||||
meths.win_set_option(win, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg")
|
||||
|
||||
if multigrid then
|
||||
screen:expect{grid=[[
|
||||
## grid 1
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[3:----------------------------------------]|
|
||||
## grid 2
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
## grid 3
|
||||
|
|
||||
## grid 4
|
||||
{7: }|
|
||||
{7:~ }|
|
||||
]], float_pos={
|
||||
[4] = { { id = 1001 }, "NW", 1, 2, 5, true };
|
||||
}, win_viewport={
|
||||
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0};
|
||||
[4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0};
|
||||
}}
|
||||
else
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }{7: }{0: }|
|
||||
{0:~ }{7:~ }{0: }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]]}
|
||||
end
|
||||
|
||||
exec_lua [[
|
||||
local buf = vim.api.nvim_create_buf(false,false)
|
||||
local win = vim.api.nvim_open_win(buf, false, {relative='editor', width=16, height=2, row=3, col=8})
|
||||
vim.api.nvim_win_set_option(win, "winhl", "EndOfBuffer:Normal")
|
||||
buf = vim.api.nvim_create_buf(false,false)
|
||||
win = vim.api.nvim_open_win(buf, true, {relative='editor', width=12, height=2, row=4, col=10})
|
||||
vim.api.nvim_win_set_option(win, "winhl", "Normal:Search,EndOfBuffer:Search")
|
||||
]]
|
||||
|
||||
if multigrid then
|
||||
screen:expect{grid=[[
|
||||
## grid 1
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[3:----------------------------------------]|
|
||||
## grid 2
|
||||
|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
## grid 3
|
||||
|
|
||||
## grid 4
|
||||
{7: }|
|
||||
{7:~ }|
|
||||
## grid 5
|
||||
{1: }|
|
||||
{1:~ }|
|
||||
## grid 6
|
||||
{17:^ }|
|
||||
{17:~ }|
|
||||
]], float_pos={
|
||||
[4] = { { id = 1001 }, "NW", 1, 2, 5, true };
|
||||
[5] = { { id = 1002 }, "NW", 1, 3, 8, true };
|
||||
[6] = { { id = 1003 }, "NW", 1, 4, 10, true };
|
||||
}, win_viewport={
|
||||
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0};
|
||||
[4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0};
|
||||
[5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0};
|
||||
[6] = {win = {id = 1003}, topline = 0, botline = 2, curline = 0, curcol = 0};
|
||||
}}
|
||||
else
|
||||
screen:expect{grid=[[
|
||||
|
|
||||
{0:~ }|
|
||||
{0:~ }{7: }{0: }|
|
||||
{0:~ }{7:~ }{1: }{7: }{0: }|
|
||||
{0:~ }{1:~ }{17:^ }{1: }{0: }|
|
||||
{0:~ }{17:~ }{0: }|
|
||||
|
|
||||
]]}
|
||||
end
|
||||
end)
|
||||
|
||||
it("correctly orders multiple opened floats (non-current last)", function()
|
||||
local buf = meths.create_buf(false,false)
|
||||
local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
|
||||
meths.win_set_option(win, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg")
|
||||
|
||||
if multigrid then
|
||||
screen:expect{grid=[[
|
||||
## grid 1
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[3:----------------------------------------]|
|
||||
## grid 2
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
## grid 3
|
||||
|
|
||||
## grid 4
|
||||
{7: }|
|
||||
{7:~ }|
|
||||
]], float_pos={
|
||||
[4] = { { id = 1001 }, "NW", 1, 2, 5, true };
|
||||
}, win_viewport={
|
||||
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0};
|
||||
[4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0};
|
||||
}}
|
||||
else
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }{7: }{0: }|
|
||||
{0:~ }{7:~ }{0: }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]]}
|
||||
end
|
||||
|
||||
exec_lua [[
|
||||
local buf = vim.api.nvim_create_buf(false,false)
|
||||
local win = vim.api.nvim_open_win(buf, true, {relative='editor', width=12, height=2, row=4, col=10})
|
||||
vim.api.nvim_win_set_option(win, "winhl", "Normal:Search,EndOfBuffer:Search")
|
||||
buf = vim.api.nvim_create_buf(false,false)
|
||||
win = vim.api.nvim_open_win(buf, false, {relative='editor', width=16, height=2, row=3, col=8})
|
||||
vim.api.nvim_win_set_option(win, "winhl", "EndOfBuffer:Normal")
|
||||
]]
|
||||
|
||||
if multigrid then
|
||||
screen:expect{grid=[[
|
||||
## grid 1
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[3:----------------------------------------]|
|
||||
## grid 2
|
||||
|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
## grid 3
|
||||
|
|
||||
## grid 4
|
||||
{7: }|
|
||||
{7:~ }|
|
||||
## grid 5
|
||||
{17:^ }|
|
||||
{17:~ }|
|
||||
## grid 6
|
||||
{1: }|
|
||||
{1:~ }|
|
||||
]], float_pos={
|
||||
[4] = { { id = 1001 }, "NW", 1, 2, 5, true };
|
||||
[5] = { { id = 1002 }, "NW", 1, 4, 10, true };
|
||||
[6] = { { id = 1003 }, "NW", 1, 3, 8, true };
|
||||
}, win_viewport={
|
||||
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0};
|
||||
[4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0};
|
||||
[5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0};
|
||||
[6] = {win = {id = 1003}, topline = 0, botline = 2, curline = 0, curcol = 0};
|
||||
}}
|
||||
else
|
||||
screen:expect{grid=[[
|
||||
|
|
||||
{0:~ }|
|
||||
{0:~ }{7: }{0: }|
|
||||
{0:~ }{7:~ }{1: }{7: }{0: }|
|
||||
{0:~ }{1:~ }{17:^ }{1: }{0: }|
|
||||
{0:~ }{17:~ }{0: }|
|
||||
|
|
||||
]]}
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
describe('with ext_multigrid', function()
|
||||
|
Loading…
Reference in New Issue
Block a user