mirror of
https://github.com/neovim/neovim.git
synced 2026-02-19 01:48:30 +00:00
fix(api): preserve WinConfig style when converting float to split #37264
Problem: When a float window with style='minimal' is converted to a split window and then changes buffer, the minimal style options get overridden. This happens because merge_win_config() clears the style field, so get_winopts() doesn't know to re-apply minimal style after restoring options from the buffer's wininfo. Solution: Save and restore the style field when clearing the config during float-to-split conversion.
This commit is contained in:
@@ -1364,6 +1364,7 @@ win_T *win_split_ins(int size, int flags, win_T *new_wp, int dir, frame_T *to_fl
|
||||
// make the contents of the new window the same as the current one
|
||||
win_init(wp, curwin, flags);
|
||||
} else if (wp->w_floating) {
|
||||
WinStyle saved_style = wp->w_config.style;
|
||||
ui_comp_remove_grid(&wp->w_grid_alloc);
|
||||
if (ui_has(kUIMultigrid)) {
|
||||
wp->w_pos_changed = true;
|
||||
@@ -1388,6 +1389,8 @@ win_T *win_split_ins(int size, int flags, win_T *new_wp, int dir, frame_T *to_fl
|
||||
// non-floating window doesn't store float config or have a border.
|
||||
merge_win_config(&wp->w_config, WIN_CONFIG_INIT);
|
||||
CLEAR_FIELD(wp->w_border_adj);
|
||||
// Restore WinConfig style. #37067
|
||||
wp->w_config.style = saved_style;
|
||||
}
|
||||
|
||||
// Going to reorganize frames now, make sure they're flat.
|
||||
|
||||
@@ -3478,5 +3478,34 @@ describe('API/win', function()
|
||||
pcall_err(api.nvim_win_set_config, old_curwin, { win = other_tp_win, split = 'right' })
|
||||
)
|
||||
end)
|
||||
|
||||
it('minimal style persists through float-to-split and buffer change #37067', function()
|
||||
-- Set all options globally
|
||||
command('set number relativenumber cursorline cursorcolumn spell list')
|
||||
command('set signcolumn=yes colorcolumn=80 statuscolumn=%l foldcolumn=2')
|
||||
local buf1 = api.nvim_create_buf(false, true)
|
||||
local win = api.nvim_open_win(buf1, true, {
|
||||
relative = 'editor',
|
||||
width = 10,
|
||||
height = 10,
|
||||
row = 5,
|
||||
col = 5,
|
||||
style = 'minimal',
|
||||
})
|
||||
-- Convert to split then change buffer
|
||||
api.nvim_win_set_config(win, { split = 'below', win = -1 })
|
||||
local buf2 = api.nvim_create_buf(false, true)
|
||||
api.nvim_win_set_buf(win, buf2)
|
||||
eq(false, api.nvim_get_option_value('number', { win = win }))
|
||||
eq(false, api.nvim_get_option_value('relativenumber', { win = win }))
|
||||
eq(false, api.nvim_get_option_value('cursorline', { win = win }))
|
||||
eq(false, api.nvim_get_option_value('cursorcolumn', { win = win }))
|
||||
eq(false, api.nvim_get_option_value('spell', { win = win }))
|
||||
eq(false, api.nvim_get_option_value('list', { win = win }))
|
||||
eq('0', api.nvim_get_option_value('foldcolumn', { win = win }))
|
||||
eq('auto', api.nvim_get_option_value('signcolumn', { win = win }))
|
||||
eq('', api.nvim_get_option_value('colorcolumn', { win = win }))
|
||||
eq('', api.nvim_get_option_value('statuscolumn', { win = win }))
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user