Skip to content

Commit 875cf87

Browse files
committed
patch 8.1.0171: typing CTRL-W n in a terminal window causes ml_get error
Problem: Typing CTRL-W n in a terminal window causes ml_get error. Solution: When resizing the terminal outside of terminal_loop() make sure the snapshot is complete.
1 parent 2338c32 commit 875cf87

3 files changed

Lines changed: 33 additions & 2 deletions

File tree

src/terminal.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3134,13 +3134,16 @@ term_update_window(win_T *wp)
31343134

31353135
if (term->tl_rows != newrows || term->tl_cols != newcols)
31363136
{
3137-
3138-
31393137
term->tl_vterm_size_changed = TRUE;
31403138
vterm_set_size(vterm, newrows, newcols);
31413139
ch_log(term->tl_job->jv_channel, "Resizing terminal to %d lines",
31423140
newrows);
31433141
term_report_winsize(term, newrows, newcols);
3142+
3143+
// Updating the terminal size will cause the snapshot to be cleared.
3144+
// When not in terminal_loop() we need to restore it.
3145+
if (term != in_terminal_loop)
3146+
may_move_terminal_to_buffer(term, FALSE);
31443147
}
31453148

31463149
/* The cursor may have been moved when resizing. */

src/testdir/test_terminal.vim

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,32 @@ func Test_terminwinscroll()
15251525
exe buf . 'bwipe!'
15261526
endfunc
15271527

1528+
" Resizing the terminal window caused an ml_get error.
1529+
" TODO: This does not reproduce the original problem.
1530+
func Test_terminal_resize()
1531+
set statusline=x
1532+
terminal
1533+
call assert_equal(2, winnr('$'))
1534+
1535+
" Fill the terminal with text.
1536+
if has('win32')
1537+
call feedkeys("dir\<CR>", 'xt')
1538+
else
1539+
call feedkeys("ls\<CR>", 'xt')
1540+
endif
1541+
" Go to Terminal-Normal mode for a moment.
1542+
call feedkeys("\<C-W>N", 'xt')
1543+
" Open a new window
1544+
call feedkeys("i\<C-W>n", 'xt')
1545+
call assert_equal(3, winnr('$'))
1546+
redraw
1547+
1548+
close
1549+
call assert_equal(2, winnr('$'))
1550+
call feedkeys("exit\<CR>", 'xt')
1551+
set statusline&
1552+
endfunc
1553+
15281554
" must be nearly the last, we can't go back from GUI to terminal
15291555
func Test_zz1_terminal_in_gui()
15301556
if !CanRunGui()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,8 @@ static char *(features[]) =
789789

790790
static int included_patches[] =
791791
{ /* Add new patch number below this line */
792+
/**/
793+
171,
792794
/**/
793795
170,
794796
/**/

0 commit comments

Comments
 (0)