From 045afa9e8a08ac11f7e306b1fa01fcf7214e8e8f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 29 Sep 2024 18:38:17 +0800 Subject: [PATCH] fix(float): properly find last window of tabpage (#30571) (cherry picked from commit df915f3afccb2717bc62e7b8649d76885cc3916c) --- src/nvim/winfloat.c | 2 +- test/functional/ui/float_spec.lua | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/nvim/winfloat.c b/src/nvim/winfloat.c index 331bbe5a3c..793f26cfb5 100644 --- a/src/nvim/winfloat.c +++ b/src/nvim/winfloat.c @@ -58,7 +58,7 @@ win_T *win_new_float(win_T *wp, bool last, WinConfig fconfig, Error *err) if (!tp) { return NULL; } - tp_last = tp->tp_lastwin; + tp_last = tp == curtab ? lastwin : tp->tp_lastwin; while (tp_last->w_floating && tp_last->w_prev) { tp_last = tp_last->w_prev; } diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index b20172eb09..f88d546752 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -662,6 +662,22 @@ describe('float window', function() screen:detach() end) + it('no crash with relative="win" after %bdelete #30569', function() + exec([[ + botright vsplit + %bdelete + ]]) + api.nvim_open_win(0, false, { + relative = 'win', + win = 0, + row = 0, + col = 5, + width = 5, + height = 5, + }) + assert_alive() + end) + describe('with only one tabpage,', function() local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1} local old_buf, old_win