Skip to content


patch 8.1.0171: typing CTRL-W n in a terminal window causes ml_get error
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brammool committed Jul 8, 2018
1 parent 2338c32 commit 875cf87
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/terminal.c
Expand Up @@ -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",
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. */
Expand Down
26 changes: 26 additions & 0 deletions src/testdir/test_terminal.vim
Expand Up @@ -1525,6 +1525,32 @@ func Test_terminwinscroll()
exe buf . 'bwipe!'

" Resizing the terminal window caused an ml_get error.
" TODO: This does not reproduce the original problem.
func Test_terminal_resize()
set statusline=x
call assert_equal(2, winnr('$'))

" Fill the terminal with text.
if has('win32')
call feedkeys("dir\<CR>", 'xt')
call feedkeys("ls\<CR>", 'xt')
" Go to Terminal-Normal mode for a moment.
call feedkeys("\<C-W>N", 'xt')
" Open a new window
call feedkeys("i\<C-W>n", 'xt')
call assert_equal(3, winnr('$'))

call assert_equal(2, winnr('$'))
call feedkeys("exit\<CR>", 'xt')
set statusline&

" must be nearly the last, we can't go back from GUI to terminal
func Test_zz1_terminal_in_gui()
if !CanRunGui()
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -789,6 +789,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
Expand Down

0 comments on commit 875cf87

Please sign in to comment.