diff --git a/src/nvim/winfloat.c b/src/nvim/winfloat.c index 0d8b0ee84a..de9fe13417 100644 --- a/src/nvim/winfloat.c +++ b/src/nvim/winfloat.c @@ -100,8 +100,9 @@ win_T *win_new_float(win_T *wp, bool last, WinConfig fconfig, Error *err) int dir; winframe_remove(wp, &dir, NULL, NULL); XFREE_CLEAR(wp->w_frame); - win_comp_pos(); // recompute window positions win_remove(wp, NULL); + last_status(false); // may need to remove last status line + win_comp_pos(); // recompute window positions win_append(lastwin_nofloating(NULL), wp, NULL); } wp->w_floating = true; diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 579eb88663..d75dc78142 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -3241,6 +3241,46 @@ describe('API/win', function() pcall_err(api.nvim_win_set_config, win, cfg) ) end) + + it('removes last statusline if needed', function() + local screen = Screen.new(30, 9) + command('set laststatus=1 | botright split') + screen:expect([[ + | + {1:~ }|*2 + {2:[No Name] }| + ^ | + {1:~ }|*2 + {3:[No Name] }| + | + ]]) + api.nvim_win_set_config(0, { relative = 'editor', row = 0, col = 0, width = 4, height = 4 }) + screen:expect([[ + {4:^ } | + {11:~ }{1: }|*3 + {1:~ }|*4 + | + ]]) + command('quit | set laststatus=2 | botright split') + screen:expect([[ + | + {1:~ }|*2 + {2:[No Name] }| + ^ | + {1:~ }|*2 + {3:[No Name] }| + | + ]]) + api.nvim_win_set_config(0, { relative = 'editor', row = 1, col = 5, width = 4, height = 4 }) + screen:expect([[ + | + {1:~ }{4:^ }{1: }| + {1:~ }{11:~ }{1: }|*3 + {1:~ }|*2 + {2:[No Name] }| + | + ]]) + end) end) describe('get_config', function() diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index a3d4289520..9d3e83352c 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -7758,12 +7758,11 @@ describe('float window', function() screen:expect { grid = [[ ## grid 1 - [2:----------------------------------------]|*5 - {5:[No Name] [+] }| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }|*4 + {0:~ }|*5 ## grid 3 | ## grid 4 diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 4159563fcf..223088b3e8 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -2346,8 +2346,7 @@ describe('ui/ext_messages', function() screen:expect([[ | {1:~ }{4:^ }{1: }| - {1:~ }|*21 - {2:[No Name] }| + {1:~ }|*22 ]]) end) diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index d9501b8400..d60992974a 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -1795,9 +1795,14 @@ local function fmt_ext_state(name, state) elseif name == 'float_pos' then local str = '{\n' for k, v in pairs(state) do - str = str .. ' [' .. k .. '] = {' .. v[1] - for i = 2, #v do - str = str .. ', ' .. inspect(v[i]) + str = str .. ' [' .. k .. '] = {' + if v.external then + str = str .. ' external = true ' + else + str = str .. v[1] + for i = 2, #v do + str = str .. ', ' .. inspect(v[i]) + end end str = str .. '};\n' end