neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 5c156fdc6421fb4f342394319caf5d1f64cca915
parent 4260f73e139601f7118b631e4f7ea4b6029e353f
Author: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Date:   Fri,  6 Feb 2026 16:33:25 +0000

fix(terminal): update size after closing window

Problem: terminal's size may not update after one of its windows close.

Solution: call terminal_check_size after closing a window.

Disable test for Windows, as for some reason it only shows a few lines...

Diffstat:
Msrc/nvim/window.c | 6++++++
Mtest/functional/terminal/window_spec.lua | 66+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/src/nvim/window.c b/src/nvim/window.c @@ -3039,6 +3039,9 @@ int win_close(win_T *win, bool free_buf, bool force) win_fix_scroll(false); } } + if (bufref.br_buf && bufref_valid(&bufref) && bufref.br_buf->terminal) { + terminal_check_size(bufref.br_buf->terminal); + } if (close_curwin) { win_enter_ext(wp, WEE_CURWIN_INVALID | WEE_TRIGGER_ENTER_AUTOCMDS @@ -3264,6 +3267,9 @@ bool win_close_othertab(win_T *win, int free_buf, tabpage_T *tp, bool force) int dir; win_free_mem(win, &dir, tp); + if (bufref.br_buf && bufref_valid(&bufref) && bufref.br_buf->terminal) { + terminal_check_size(bufref.br_buf->terminal); + } if (free_tp_idx > 0) { free_tabpage(tp); diff --git a/test/functional/terminal/window_spec.lua b/test/functional/terminal/window_spec.lua @@ -424,9 +424,11 @@ describe(':terminal window', function() ]]) end) - it('in new tabpage has correct terminal size', function() + it('updates terminal size', function() + skip(is_os('win'), "Windows doesn't show all lines?") screen:set_default_attr_ids({ [1] = { reverse = true }, + [2] = { background = 225, foreground = Screen.colors.Gray0 }, [3] = { bold = true }, [17] = { background = 2, foreground = Screen.colors.Grey0 }, [18] = { background = 2, foreground = 8 }, @@ -453,6 +455,68 @@ describe(':terminal window', function() | {3:-- TERMINAL --} | ]]) + + command('quit | botright split') + -- NOTE: right window's cursor not on the last line, so it's not tailing. + screen:expect([[ + rows: 5, cols: 50 │rows: 5, cols: 25 | + rows: 2, cols: 50 │rows: 5, cols: 50 | + {18:foo [-] foo [-] }| + rows: 2, cols: 50 | + ^ | + {17:foo [-] }| + {3:-- TERMINAL --} | + ]]) + command('quit') + screen:expect([[ + rows: 5, cols: 25 │tty ready | + rows: 5, cols: 50 │rows: 5, cols: 25 | + rows: 2, cols: 50 │rows: 5, cols: 50 | + rows: 5, cols: 25 │rows: 2, cols: 50 | + ^ │rows: 5, cols: 25 | + {17:foo [-] }{18:foo [-] }| + {3:-- TERMINAL --} | + ]]) + command('call nvim_open_win(0, 0, #{relative: "editor", row: 0, col: 0, width: 40, height: 3})') + screen:expect([[ + {2:rows: 5, cols: 25 } | + {2:rows: 5, cols: 40 } 25 | + {2: } 50 | + rows: 5, cols: 40 │rows: 2, cols: 50 | + ^ │rows: 5, cols: 25 | + {17:foo [-] }{18:foo [-] }| + {3:-- TERMINAL --} | + ]]) + command('fclose!') + screen:expect([[ + rows: 2, cols: 50 │tty ready | + rows: 5, cols: 25 │rows: 5, cols: 25 | + rows: 5, cols: 40 │rows: 5, cols: 50 | + rows: 5, cols: 25 │rows: 2, cols: 50 | + ^ │rows: 5, cols: 25 | + {17:foo [-] }{18:foo [-] }| + {3:-- TERMINAL --} | + ]]) + command('tab split') + screen:expect([[ + {19: }{20:2}{19: foo }{3: foo }{1: }{19:X}| + rows: 5, cols: 25 | + rows: 5, cols: 40 | + rows: 5, cols: 25 | + rows: 5, cols: 50 | + ^ | + {3:-- TERMINAL --} | + ]]) + command('tabfirst | tabonly') + screen:expect([[ + rows: 5, cols: 40 │tty ready | + rows: 5, cols: 25 │rows: 5, cols: 25 | + rows: 5, cols: 50 │rows: 5, cols: 50 | + rows: 5, cols: 25 │rows: 2, cols: 50 | + ^ │rows: 5, cols: 25 | + {17:foo [-] }{18:foo [-] }| + {3:-- TERMINAL --} | + ]]) end) it('restores window options when switching terminals', function()