diff --git a/src/nvim/window.c b/src/nvim/window.c index 3f4c24bf17..65012f8564 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -4245,6 +4245,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); diff --git a/test/functional/terminal/window_spec.lua b/test/functional/terminal/window_spec.lua index 34088bb699..2dcaf203d4 100644 --- a/test/functional/terminal/window_spec.lua +++ b/test/functional/terminal/window_spec.lua @@ -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()