mirror of
https://github.com/neovim/neovim.git
synced 2026-08-28 18:11:47 +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;
|
int dir;
|
||||||
winframe_remove(wp, &dir, NULL, NULL);
|
winframe_remove(wp, &dir, NULL, NULL);
|
||||||
XFREE_CLEAR(wp->w_frame);
|
XFREE_CLEAR(wp->w_frame);
|
||||||
win_comp_pos(); // recompute window positions
|
|
||||||
win_remove(wp, NULL);
|
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);
|
win_append(lastwin_nofloating(NULL), wp, NULL);
|
||||||
}
|
}
|
||||||
wp->w_floating = true;
|
wp->w_floating = true;
|
||||||
|
|||||||
@@ -3241,6 +3241,46 @@ describe('API/win', function()
|
|||||||
pcall_err(api.nvim_win_set_config, win, cfg)
|
pcall_err(api.nvim_win_set_config, win, cfg)
|
||||||
)
|
)
|
||||||
end)
|
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)
|
end)
|
||||||
|
|
||||||
describe('get_config', function()
|
describe('get_config', function()
|
||||||
|
|||||||
@@ -7758,12 +7758,11 @@ describe('float window', function()
|
|||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
## grid 1
|
## grid 1
|
||||||
[2:----------------------------------------]|*5
|
[2:----------------------------------------]|*6
|
||||||
{5:[No Name] [+] }|
|
|
||||||
[3:----------------------------------------]|
|
[3:----------------------------------------]|
|
||||||
## grid 2
|
## grid 2
|
||||||
x |
|
x |
|
||||||
{0:~ }|*4
|
{0:~ }|*5
|
||||||
## grid 3
|
## grid 3
|
||||||
|
|
|
|
||||||
## grid 4
|
## grid 4
|
||||||
|
|||||||
@@ -2346,8 +2346,7 @@ describe('ui/ext_messages', function()
|
|||||||
screen:expect([[
|
screen:expect([[
|
||||||
|
|
|
|
||||||
{1:~ }{4:^ }{1: }|
|
{1:~ }{4:^ }{1: }|
|
||||||
{1:~ }|*21
|
{1:~ }|*22
|
||||||
{2:[No Name] }|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -1795,9 +1795,14 @@ local function fmt_ext_state(name, state)
|
|||||||
elseif name == 'float_pos' then
|
elseif name == 'float_pos' then
|
||||||
local str = '{\n'
|
local str = '{\n'
|
||||||
for k, v in pairs(state) do
|
for k, v in pairs(state) do
|
||||||
str = str .. ' [' .. k .. '] = {' .. v[1]
|
str = str .. ' [' .. k .. '] = {'
|
||||||
for i = 2, #v do
|
if v.external then
|
||||||
str = str .. ', ' .. inspect(v[i])
|
str = str .. ' external = true '
|
||||||
|
else
|
||||||
|
str = str .. v[1]
|
||||||
|
for i = 2, #v do
|
||||||
|
str = str .. ', ' .. inspect(v[i])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
str = str .. '};\n'
|
str = str .. '};\n'
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user