# HG changeset patch # User Christian Brabandt # Date 1531076407 -7200 # Node ID 83b870d9ac4b166598be6e6024ca5dad1c34ba2a # Parent d8b3135ad9a4b2cb78ab07b49c206251393de639 patch 8.1.0171: typing CTRL-W n in a terminal window causes ml_get error commit https://github.com/vim/vim/commit/875cf8789426cc258d85358ea2c86744a5a87b16 Author: Bram Moolenaar Date: Sun Jul 8 20:49:07 2018 +0200 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. diff --git a/src/terminal.c b/src/terminal.c --- a/src/terminal.c +++ b/src/terminal.c @@ -3134,13 +3134,16 @@ term_update_window(win_T *wp) if (term->tl_rows != newrows || term->tl_cols != newcols) { - - term->tl_vterm_size_changed = TRUE; vterm_set_size(vterm, newrows, newcols); ch_log(term->tl_job->jv_channel, "Resizing terminal to %d lines", newrows); term_report_winsize(term, newrows, newcols); + + // Updating the terminal size will cause the snapshot to be cleared. + // When not in terminal_loop() we need to restore it. + if (term != in_terminal_loop) + may_move_terminal_to_buffer(term, FALSE); } /* The cursor may have been moved when resizing. */ diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -1525,6 +1525,32 @@ func Test_terminwinscroll() exe buf . 'bwipe!' endfunc +" Resizing the terminal window caused an ml_get error. +" TODO: This does not reproduce the original problem. +func Test_terminal_resize() + set statusline=x + terminal + call assert_equal(2, winnr('$')) + + " Fill the terminal with text. + if has('win32') + call feedkeys("dir\", 'xt') + else + call feedkeys("ls\", 'xt') + endif + " Go to Terminal-Normal mode for a moment. + call feedkeys("\N", 'xt') + " Open a new window + call feedkeys("i\n", 'xt') + call assert_equal(3, winnr('$')) + redraw + + close + call assert_equal(2, winnr('$')) + call feedkeys("exit\", 'xt') + set statusline& +endfunc + " must be nearly the last, we can't go back from GUI to terminal func Test_zz1_terminal_in_gui() if !CanRunGui() diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -790,6 +790,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 171, +/**/ 170, /**/ 169,