mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(float): "Not enough room" error for 1-line float #25192
Problem: set winbar on a floating window which only have one row will cause crash. Solution: when new floating window only have one room don't copy winbar from target window" Fix #19464
This commit is contained in:
parent
dc33879dc2
commit
cff5fa49fc
@ -22,6 +22,7 @@
|
|||||||
#include "nvim/move.h"
|
#include "nvim/move.h"
|
||||||
#include "nvim/option.h"
|
#include "nvim/option.h"
|
||||||
#include "nvim/option_defs.h"
|
#include "nvim/option_defs.h"
|
||||||
|
#include "nvim/option_vars.h"
|
||||||
#include "nvim/optionstr.h"
|
#include "nvim/optionstr.h"
|
||||||
#include "nvim/pos_defs.h"
|
#include "nvim/pos_defs.h"
|
||||||
#include "nvim/strings.h"
|
#include "nvim/strings.h"
|
||||||
@ -65,6 +66,12 @@ win_T *win_new_float(win_T *wp, bool last, WinConfig fconfig, Error *err)
|
|||||||
}
|
}
|
||||||
wp = win_alloc(tp_last, false);
|
wp = win_alloc(tp_last, false);
|
||||||
win_init(wp, curwin, 0);
|
win_init(wp, curwin, 0);
|
||||||
|
if (wp->w_p_wbr != NULL && fconfig.height == 1) {
|
||||||
|
if (wp->w_p_wbr != empty_string_option) {
|
||||||
|
free_string_option(wp->w_p_wbr);
|
||||||
|
}
|
||||||
|
wp->w_p_wbr = empty_string_option;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(!last);
|
assert(!last);
|
||||||
assert(!wp->w_floating);
|
assert(!wp->w_floating);
|
||||||
|
@ -9845,6 +9845,35 @@ describe('float window', function()
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("1-line float does not inherit 'winbar' #19464", function()
|
||||||
|
local res = exec_lua([[
|
||||||
|
local win = vim.api.nvim_get_current_win()
|
||||||
|
vim.wo[win].winbar = '%f'
|
||||||
|
local grp = vim.api.nvim_create_augroup('asdf', { clear = true })
|
||||||
|
vim.api.nvim_create_autocmd('WinEnter', {
|
||||||
|
group = grp,
|
||||||
|
pattern = '*',
|
||||||
|
desc = 'winbar crash?',
|
||||||
|
callback = function()
|
||||||
|
vim.wo[win].winbar = '%f'
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
local buf = vim.api.nvim_create_buf(false, true)
|
||||||
|
local float_winid = vim.api.nvim_open_win(buf, true, {
|
||||||
|
relative = 'win',
|
||||||
|
win = win,
|
||||||
|
border = 'single',
|
||||||
|
col = 1,
|
||||||
|
row = 1,
|
||||||
|
height = 1,
|
||||||
|
width = 40,
|
||||||
|
})
|
||||||
|
return {vim.wo[win].winbar, vim.wo[float_winid].winbar}
|
||||||
|
]])
|
||||||
|
eq({"%f", ""}, res)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe('with ext_multigrid', function()
|
describe('with ext_multigrid', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user