mirror of
https://github.com/neovim/neovim.git
synced 2026-03-31 04:42:03 +00:00
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...
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user