mirror of
https://github.com/neovim/neovim.git
synced 2026-03-31 21:02:11 +00:00
fix(winfloat): last_status when changing split to floatwin
Problem: converting a split to a floatwin may not remove the last statusline when needed. (e.g: 'ls' is 1) Solution: call last_status/win_comp_pos in win_new_float, after win_remove. Also fix float_pos formatting for screen snapshots so it doesn't give a nil error for external windows. Not an issue from this PR.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2346,8 +2346,7 @@ describe('ui/ext_messages', function()
|
||||
screen:expect([[
|
||||
|
|
||||
{1:~ }{4:^ }{1: }|
|
||||
{1:~ }|*21
|
||||
{2:[No Name] }|
|
||||
{1:~ }|*22
|
||||
]])
|
||||
end)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user