mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 12:28:18 +00:00
fix(api): don't use 'winborder' when reconfiguring float (#32984)
Problem: Reconfiguring a float window applies the global 'winborder'. Solution: - Ignore 'winborder' when reconfiguring a float window. - Still apply 'winborder' when converting a split to a float window.
This commit is contained in:
@@ -1280,7 +1280,7 @@ static bool parse_win_config(win_T *wp, Dict(win_config) *config, WinConfig *fco
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
border_style = config->border;
|
border_style = config->border;
|
||||||
} else if (*p_winborder != NUL) {
|
} else if (*p_winborder != NUL && (wp == NULL || !wp->w_floating)) {
|
||||||
border_style = CSTR_AS_OBJ(p_winborder);
|
border_style = CSTR_AS_OBJ(p_winborder);
|
||||||
}
|
}
|
||||||
if (border_style.type != kObjectTypeNil) {
|
if (border_style.type != kObjectTypeNil) {
|
||||||
|
@@ -1907,6 +1907,38 @@ describe('API/win', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('set_config', function()
|
describe('set_config', function()
|
||||||
|
it("uses 'winborder' when converting a split to a floating window", function()
|
||||||
|
api.nvim_set_option_value('winborder', 'single', {})
|
||||||
|
command('split')
|
||||||
|
local winid = api.nvim_get_current_win()
|
||||||
|
-- Convert split to float without specifying border
|
||||||
|
api.nvim_win_set_config(winid, {
|
||||||
|
relative = 'editor',
|
||||||
|
row = 2,
|
||||||
|
col = 2,
|
||||||
|
width = 10,
|
||||||
|
height = 5,
|
||||||
|
})
|
||||||
|
local config = api.nvim_win_get_config(winid)
|
||||||
|
eq('┌', config.border[1])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('erases border of a floating window when converting to split window', function()
|
||||||
|
api.nvim_set_option_value('winborder', 'single', {})
|
||||||
|
local winid = api.nvim_open_win(api.nvim_create_buf(false, false), false, {
|
||||||
|
relative = 'editor',
|
||||||
|
row = 2,
|
||||||
|
col = 2,
|
||||||
|
width = 10,
|
||||||
|
height = 5,
|
||||||
|
})
|
||||||
|
local config = api.nvim_win_get_config(winid)
|
||||||
|
eq('┌', config.border[1])
|
||||||
|
api.nvim_win_set_config(winid, { split = 'right', win = 0 })
|
||||||
|
config = api.nvim_win_get_config(winid)
|
||||||
|
eq(nil, config.border)
|
||||||
|
end)
|
||||||
|
|
||||||
it('moves a split into a float', function()
|
it('moves a split into a float', function()
|
||||||
local win = api.nvim_open_win(0, true, {
|
local win = api.nvim_open_win(0, true, {
|
||||||
vertical = false,
|
vertical = false,
|
||||||
|
@@ -10088,7 +10088,7 @@ describe('float window', function()
|
|||||||
-- respect config.border
|
-- respect config.border
|
||||||
command('set winborder=rounded')
|
command('set winborder=rounded')
|
||||||
config.border = 'single'
|
config.border = 'single'
|
||||||
api.nvim_open_win(buf, false, config)
|
local winid = api.nvim_open_win(buf, false, config)
|
||||||
if multigrid then
|
if multigrid then
|
||||||
screen:expect({
|
screen:expect({
|
||||||
grid = [[
|
grid = [[
|
||||||
@@ -10153,6 +10153,11 @@ describe('float window', function()
|
|||||||
]])
|
]])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- don't use winborder when reconfig a floating window
|
||||||
|
config.border = nil
|
||||||
|
api.nvim_win_set_config(winid, config)
|
||||||
|
screen:expect_unchanged()
|
||||||
|
command('fclose!')
|
||||||
-- it is currently not supported.
|
-- it is currently not supported.
|
||||||
eq('Vim(set):E474: Invalid argument: winborder=custom', pcall_err(command, 'set winborder=custom'))
|
eq('Vim(set):E474: Invalid argument: winborder=custom', pcall_err(command, 'set winborder=custom'))
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user