From ba600c495fcf1ae46ece1a1c8e6a3516023bbfdf Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 10 Jan 2026 22:28:45 +0800 Subject: [PATCH] fix(session): window sizes not stored with float windows (#37344) (cherry picked from commit 2d3dc070ce6b0db28bc7c7ae36541ef518fdeb08) --- src/nvim/ex_session.c | 2 +- test/functional/ex_cmds/mksession_spec.lua | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index ed05d3ee95..1b3ca9b47c 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -787,7 +787,7 @@ static int makeopens(FILE *fd, char *dirnow) for (win_T *wp = tab_firstwin; wp != NULL; wp = wp->w_next) { if (ses_do_win(wp)) { nr++; - } else { + } else if (!wp->w_floating) { restore_size = false; } if (curwin == wp) { diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua index 95e118d570..f41723397d 100644 --- a/test/functional/ex_cmds/mksession_spec.lua +++ b/test/functional/ex_cmds/mksession_spec.lua @@ -232,6 +232,11 @@ describe(':mksession', function() local tmpfile = file_prefix .. '-tmpfile-float' command('edit ' .. tmpfile) + eq(80, fn.winwidth(1)) + command('30vsplit') + eq(2, #api.nvim_list_wins()) + eq(30, fn.winwidth(1)) + eq(49, fn.winwidth(2)) local buf = api.nvim_create_buf(false, true) local config = { relative = 'editor', @@ -243,6 +248,7 @@ describe(':mksession', function() style = 'minimal', } api.nvim_open_win(buf, false, config) + eq(3, #api.nvim_list_wins()) local cmdheight = api.nvim_get_option_value('cmdheight', {}) command('mksession ' .. session_file) @@ -252,9 +258,12 @@ describe(':mksession', function() command('source ' .. session_file) eq(tmpfile, fn.expand('%')) - -- Check that there is only a single window, which indicates the floating + -- Check that there are only two windows, which indicates the floating -- window was not restored. - eq(1, fn.winnr('$')) + -- Don't use winnr('$') as that doesn't count unfocusable floating windows. + eq(2, #api.nvim_list_wins()) + eq(30, fn.winwidth(1)) + eq(49, fn.winwidth(2)) -- The command-line height should remain the same as it was. eq(cmdheight, api.nvim_get_option_value('cmdheight', {}))