Skip to content

Commit d07cbb2

Browse files
committed
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.
1 parent 61217e3 commit d07cbb2

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/nvim/window.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4279,6 +4279,10 @@ int win_new_tabpage(int after, char *filename)
42794279
newtp->tp_topframe = topframe;
42804280
last_status(false);
42814281

4282+
if (curbuf->terminal) {
4283+
terminal_check_size(curbuf->terminal);
4284+
}
4285+
42824286
redraw_all_later(UPD_NOT_VALID);
42834287

42844288
tabpage_check_windows(old_curtab);

test/functional/terminal/window_spec.lua

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local t = require('test.testutil')
22
local n = require('test.functional.testnvim')()
3+
local Screen = require('test.functional.ui.screen')
34

45
local tt = require('test.functional.testterm')
56
local feed_data = tt.feed_data
@@ -383,6 +384,37 @@ describe(':terminal window', function()
383384
]])
384385
end)
385386

387+
it('in new tabpage has correct terminal size', function()
388+
screen:set_default_attr_ids({
389+
[1] = { reverse = true },
390+
[3] = { bold = true },
391+
[17] = { background = 2, foreground = Screen.colors.Grey0 },
392+
[18] = { background = 2, foreground = 8 },
393+
[19] = { underline = true, foreground = Screen.colors.Grey0, background = 7 },
394+
[20] = { underline = true, foreground = 5, background = 7 },
395+
})
396+
397+
command('file foo | vsplit')
398+
screen:expect([[
399+
tty ready │tty ready |
400+
rows: 5, cols: 25 │rows: 5, cols: 25 |
401+
^ │ |
402+
│ |*2
403+
{17:foo [-] }{18:foo [-] }|
404+
{3:-- TERMINAL --} |
405+
]])
406+
command('tab split')
407+
screen:expect([[
408+
{19: }{20:2}{19: foo }{3: foo }{1: }{19:X}|
409+
tty ready |
410+
rows: 5, cols: 25 |
411+
rows: 5, cols: 50 |
412+
^ |
413+
|
414+
{3:-- TERMINAL --} |
415+
]])
416+
end)
417+
386418
it('not unnecessarily redrawn by events', function()
387419
eq('t', eval('mode()'))
388420
exec_lua(function()

0 commit comments

Comments
 (0)