fix(terminal): check size when creating new tabpage

Problem: when creating a new tabpage with a terminal window, terminal size is
not updated if there is no statusline.

Solution: do not rely on last_status to implicitly call terminal_check_size as a
side effect of making room for a statusline; call it directly.
This commit is contained in:
Sean Dewar
2025-03-03 14:19:32 +00:00
parent 61217e3618
commit d07cbb2f42
2 changed files with 36 additions and 0 deletions

View File

@@ -4279,6 +4279,10 @@ int win_new_tabpage(int after, char *filename)
newtp->tp_topframe = topframe;
last_status(false);
if (curbuf->terminal) {
terminal_check_size(curbuf->terminal);
}
redraw_all_later(UPD_NOT_VALID);
tabpage_check_windows(old_curtab);

View File

@@ -1,5 +1,6 @@
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local tt = require('test.functional.testterm')
local feed_data = tt.feed_data
@@ -383,6 +384,37 @@ describe(':terminal window', function()
]])
end)
it('in new tabpage has correct terminal size', function()
screen:set_default_attr_ids({
[1] = { reverse = true },
[3] = { bold = true },
[17] = { background = 2, foreground = Screen.colors.Grey0 },
[18] = { background = 2, foreground = 8 },
[19] = { underline = true, foreground = Screen.colors.Grey0, background = 7 },
[20] = { underline = true, foreground = 5, background = 7 },
})
command('file foo | vsplit')
screen:expect([[
tty ready │tty ready |
rows: 5, cols: 25 │rows: 5, cols: 25 |
^ │ |
│ |*2
{17:foo [-] }{18:foo [-] }|
{3:-- TERMINAL --} |
]])
command('tab split')
screen:expect([[
{19: }{20:2}{19: foo }{3: foo }{1: }{19:X}|
tty ready |
rows: 5, cols: 25 |
rows: 5, cols: 50 |
^ |
|
{3:-- TERMINAL --} |
]])
end)
it('not unnecessarily redrawn by events', function()
eq('t', eval('mode()'))
exec_lua(function()