fix(float): clamp floating window above cmdline #37899

Problem:  A float whose zindex is below the cmdline can be enlarged and
          end up behind the cmdline.
Solution: Clamp height of such windows to not extend beyond 'cmdheight'.
This commit is contained in:
luukvbaal
2026-02-16 15:33:32 +01:00
committed by GitHub
parent 249f305bbc
commit d131d67e67
2 changed files with 92 additions and 7 deletions

View File

@@ -5028,9 +5028,9 @@ describe('float window', function()
}
else
screen:expect([[
{1:such } |
{0:~ }{1:very }{0: }|
^ |
{1:very } |
{0:~ }{1:^float }{0: }|
|
]])
end
@@ -10924,7 +10924,7 @@ describe('float window', function()
{0:~ }{5:│}{2:~}{5:│}{2:~}{5:│┌──┐│}{2: }{5:││}{0: }|
{0:~ }{5:│}{2:~}{5:│}{2:~}{5:││}{1: }{5:││}{2: }{5:││}{0: }|
{0:~ }{5:│}{2:~}{5:│}{2:~}{5:││}{2:~ }{5:││}{2: }{5:││}{0: }|
{0:~ }{5:│}{2:~}{5:│}{2:~}{5:└└──┘┘}{2: }{5:││}{0: }|
{0:~ }{5:└─└─└└──┘┘─┘┘}{0: }|
|
]])
end
@@ -10966,7 +10966,7 @@ describe('float window', function()
^ {5:┌─┌─┌────┐─┐┐} |
{0:~ }{5:│}{1: }{5:│}{1: }{5:│}{1: }{5:│}{1: }{5:││}{0: }|
{0:~ }{5:│}{2:~}{5:│}{2:~}{5:│}{2:~ }{5:│}{2: }{5:││}{0: }|*3
{0:~ }{5:│}{2:~}{5:│}{2:~}{5:└────┘}{2: }{5:││}{0: }|
{0:~ }{5:└─└─└────┘─┘┘}{0: }|
|
]])
end
@@ -11002,7 +11002,8 @@ describe('float window', function()
screen:expect([[
^ {5:┌─┌────────┐┐} |
{0:~ }{5:│}{1: }{5:│}{1: }{5:││}{0: }|
{0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }|*4
{0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }|*3
{0:~ }{5:└─└────────┘┘}{0: }|
|
]])
end
@@ -11730,6 +11731,89 @@ describe('float window', function()
screen:expect { mode = 'cmdline_normal' }
end
end)
it("window is not enlarged behind 'cmdheight'", function()
local opts = { relative = 'editor', width = 10, height = 4, row = 0, col = 0, zindex = 199 }
opts.border = 'single'
api.nvim_open_win(0, true, opts)
opts.zindex, opts.col = 200, 12
local above = api.nvim_open_win(0, false, opts)
command('echo "cmdline" | wincmd +')
if multigrid then
screen:expect({
grid = [[
## grid 1
[2:----------------------------------------]|*6
[3:----------------------------------------]|
## grid 2
|
{0:~ }|*5
## grid 3
cmdline |
## grid 4
{5:┌──────────┐}|
{5:│}{1:^ }{5:│}|
{5:│}{2:~ }{5:│}|*4
{5:└──────────┘}|
## grid 5
{5:┌──────────┐}|
{5:│}{1: }{5:│}|
{5:│}{2:~ }{5:│}|*3
{5:└──────────┘}|
]],
float_pos = {
[5] = { 1002, 'NW', 1, 0, 12, true, 200, 3, 0, 12 },
[4] = { 1001, 'NW', 1, 0, 0, true, 199, 1, 0, 0 },
},
})
else
screen:expect([[
{5:┌──────────┐┌──────────┐} |
{5:│}{1:^ }{5:││}{1: }{5:│}{0: }|
{5:│}{2:~ }{5:││}{2:~ }{5:│}{0: }|*3
{5:└──────────┘└──────────┘}{0: }|
cmdline |
]])
end
api.nvim_set_current_win(above)
command('wincmd +')
if multigrid then
screen:expect({
grid = [[
## grid 1
[2:----------------------------------------]|*6
[3:----------------------------------------]|
## grid 2
|
{0:~ }|*5
## grid 3
cmdline |
## grid 4
{5:┌──────────┐}|
{5:│}{1: }{5:│}|
{5:│}{2:~ }{5:│}|*4
{5:└──────────┘}|
## grid 5
{5:┌──────────┐}|
{5:│}{1:^ }{5:│}|
{5:│}{2:~ }{5:│}|*4
{5:└──────────┘}|
]],
float_pos = {
[5] = { 1002, 'NW', 1, 0, 12, true, 200, 3, 0, 12 },
[4] = { 1001, 'NW', 1, 0, 0, true, 199, 1, 0, 0 },
},
})
else
screen:expect([[
{5:┌──────────┐┌──────────┐} |
{5:│}{1: }{5:││}{1:^ }{5:│}{0: }|
{5:│}{2:~ }{5:││}{2:~ }{5:│}{0: }|*3
{5:└──────────┘│}{2:~ }{5:│}{0: }|
cmdline {5:└──────────┘} |
]])
end
end)
end
describe('with ext_multigrid and actual mouse grid', function()