fix(redraw): avoid unnecessary redraws and glitches with floats+messages

fixes #20106
fixes #20229
This commit is contained in:
bfredl
2022-09-16 19:21:32 +02:00
parent 8d13b08a03
commit 00cfc1dceb
9 changed files with 523 additions and 99 deletions

View File

@@ -8147,6 +8147,366 @@ describe('float window', function()
]]}
end
end)
it('it can be resized with messages and cmdheight=0 #20106', function()
screen:try_resize(40,9)
command 'set cmdheight=0'
local buf = meths.create_buf(false,true)
local win = meths.open_win(buf, false, {relative='editor', width=40, height=4, anchor='SW', row=9, col=0, style='minimal', border="single", noautocmd=true})
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
## grid 2
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
## grid 5
{5:┌────────────────────────────────────────┐}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:└────────────────────────────────────────┘}|
]], float_pos={
[5] = {{id = 1002}, "SW", 1, 9, 0, true, 50};
}, win_viewport={
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
[5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
}}
else
screen:expect{grid=[[
^ |
{0:~ }|
{0:~ }|
{5:┌──────────────────────────────────────┐}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:└──────────────────────────────────────┘}|
]]}
end
exec_lua([[
local win = ...
vim.api.nvim_win_set_height(win, 2)
vim.api.nvim_echo({ { "" } }, false, {})
]], win)
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
## grid 2
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
## grid 5
{5:┌────────────────────────────────────────┐}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:└────────────────────────────────────────┘}|
]], float_pos={
[5] = {{id = 1002}, "SW", 1, 9, 0, true, 50};
}, win_viewport={
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
[5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
}}
else
screen:expect{grid=[[
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{5:┌──────────────────────────────────────┐}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:└──────────────────────────────────────┘}|
]]}
end
meths.win_close(win, true)
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
## grid 2
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
]], win_viewport={
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
}}
else
screen:expect{grid=[[
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
]]}
end
end)
it('it can be resized with messages and cmdheight=1', function()
screen:try_resize(40,9)
local buf = meths.create_buf(false,true)
local win = meths.open_win(buf, false, {relative='editor', width=40, height=4, anchor='SW', row=8, col=0, style='minimal', border="single", noautocmd=true})
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[3:----------------------------------------]|
## grid 2
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
|
## grid 5
{5:┌────────────────────────────────────────┐}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:└────────────────────────────────────────┘}|
]], float_pos={
[5] = {{id = 1002}, "SW", 1, 8, 0, true, 50};
}, win_viewport={
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
[5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
}}
else
screen:expect{grid=[[
^ |
{0:~ }|
{5:┌──────────────────────────────────────┐}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:└──────────────────────────────────────┘}|
|
]]}
end
exec_lua([[
-- echo prompt is blocking, so schedule
local win = ...
vim.schedule(function()
vim.api.nvim_win_set_height(win, 2)
vim.api.nvim_echo({ { "\n" } }, false, {})
end)
]], win)
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[3:----------------------------------------]|
[3:----------------------------------------]|
## grid 2
|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
|
{8:Press ENTER or type command to continue}^ |
## grid 5
{5:┌────────────────────────────────────────┐}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:└────────────────────────────────────────┘}|
]], float_pos={
[5] = {{id = 1002}, "SW", 1, 8, 0, true, 50};
}, win_viewport={
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
[5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
}}
else
screen:expect{grid=[[
|
{0:~ }|
{5:┌──────────────────────────────────────┐}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{4: }|
|
{8:Press ENTER or type command to continue}^ |
]]}
end
feed('<cr>')
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[3:----------------------------------------]|
## grid 2
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
|
## grid 5
{5:┌────────────────────────────────────────┐}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:└────────────────────────────────────────┘}|
]], float_pos={
[5] = {{id = 1002}, "SW", 1, 8, 0, true, 50};
}, win_viewport={
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
[5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
}}
else
screen:expect{grid=[[
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{5:┌──────────────────────────────────────┐}|
{5:│}{1: }{5:│}|
{5:│}{1: }{5:│}|
{5:└──────────────────────────────────────┘}|
|
]]}
end
meths.win_close(win, true)
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[3:----------------------------------------]|
## grid 2
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
|
]], win_viewport={
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
}}
else
screen:expect{grid=[[
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]]}
end
end)
end
describe('with ext_multigrid', function()