]> granicus.if.org Git - vim/commitdiff
patch 8.1.0171: typing CTRL-W n in a terminal window causes ml_get error v8.1.0171
authorBram Moolenaar <Bram@vim.org>
Sun, 8 Jul 2018 18:49:07 +0000 (20:49 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 8 Jul 2018 18:49:07 +0000 (20:49 +0200)
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.

src/terminal.c
src/testdir/test_terminal.vim
src/version.c

index 2e99a8598a8827ff36852b7ecf8245c5c3e6c54c..22b90c8332c25fec014c5aeebe247ff095f82737 100644 (file)
@@ -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. */
index 52c35aaaad5731b77b4333621a1351a7d00634de..7ab0cf8ba9a1edd136d26816aff577547ab4f780 100644 (file)
@@ -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\<CR>", 'xt')
+  else
+    call feedkeys("ls\<CR>", 'xt')
+  endif
+  " 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('$'))
+  redraw
+
+  close
+  call assert_equal(2, winnr('$'))
+  call feedkeys("exit\<CR>", '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()
index dec266d8a4992e9a6d82e4d1c90d5bb15cb9781b..2821a1b9660c0469f6c0ea82b196edd5e43907f2 100644 (file)
@@ -789,6 +789,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    171,
 /**/
     170,
 /**/