]> granicus.if.org Git - vim/commitdiff
patch 8.2.2545: errors and crash when terminal window is zero height v8.2.2545
authorBram Moolenaar <Bram@vim.org>
Tue, 23 Feb 2021 16:47:23 +0000 (17:47 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 23 Feb 2021 16:47:23 +0000 (17:47 +0100)
Problem:    Errors and crash when terminal window is zero height. (Leonid V.
            Fedorenchik)
Solution:   Do not resize when width or height is zero. (closes #7890)

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

index 9729eac8f8673a6bbbb653e982064700b86c395a..4c43ea7482e7dfbb08e7bb7cdb401433692af8d2 100644 (file)
@@ -3800,6 +3800,11 @@ term_update_window(win_T *wp)
     newrows = rows == 0 ? newrows : minsize ? MAX(rows, newrows) : rows;
     newcols = cols == 0 ? newcols : minsize ? MAX(cols, newcols) : cols;
 
+    // If no cell is visible there is no point in resizing.  Also, vterm can't
+    // handle a zero height.
+    if (newrows == 0 || newcols == 0)
+       return;
+
     if (term->tl_rows != newrows || term->tl_cols != newcols)
     {
        term->tl_vterm_size_changed = TRUE;
index 90241710ec5a44b784f669ce633e6a9ee80e4f06..3def03d7b23177b5dca73da2db13c3a5211dc8a7 100644 (file)
@@ -470,6 +470,19 @@ func Test_terminal_size()
   call delete('Xtext')
 endfunc
 
+func Test_terminal_zero_height()
+  split
+  wincmd j
+  anoremenu 1.1 WinBar.test :
+  terminal ++curwin
+  wincmd k
+  wincmd _
+  redraw
+
+  call term_sendkeys(bufnr(), "exit\r")
+  bwipe!
+endfunc
+
 func Test_terminal_curwin()
   let cmd = Get_cat_123_cmd()
   call assert_equal(1, winnr('$'))
index aa6d34380a70dbd46f35840e2974d6f9f0dc0169..dda530a3ff8d727dd99db9c68e11b2a695ea9bf1 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2545,
 /**/
     2544,
 /**/