]> granicus.if.org Git - vim/commitdiff
patch 8.2.3764: cannot see any text when window was made zero lines v8.2.3764
authorBram Moolenaar <Bram@vim.org>
Thu, 9 Dec 2021 11:57:22 +0000 (11:57 +0000)
committerBram Moolenaar <Bram@vim.org>
Thu, 9 Dec 2021 11:57:22 +0000 (11:57 +0000)
Problem:    Cannot see any text when window was made zero lines or zero
            columns.
Solution:   Ensure there is at least one line and column. (fixes #9307)

src/edit.c
src/normal.c
src/proto/window.pro
src/testdir/test_window_cmd.vim
src/version.c
src/window.c

index 686c6d429af382303489b4739fbae41c75a83539..8dd60941a043995af517ca2adba1006c2bd00ca7 100644 (file)
@@ -618,6 +618,11 @@ edit(
            c = hkmap(c);               // Hebrew mode mapping
 #endif
 
+       // If the window was made so small that nothing shows, make it at least
+       // one line and one column when typing.
+       if (KeyTyped && !KeyStuffed)
+           win_ensure_size();
+
        /*
         * Special handling of keys while the popup menu is visible or wanted
         * and the cursor is still in the completed word.  Only when there is
index 0fbfe9207699cef483046c13274e67fa49fba778..d3c4c7875cb560ddecf3a9d469c5f3828fbc2752 100644 (file)
@@ -608,6 +608,11 @@ normal_cmd(
        old_mapped_len = 0;     // do go to Insert mode
     }
 
+    // If the window was made so small that nothing shows, make it at least one
+    // line and one column when typing a command.
+    if (KeyTyped && !KeyStuffed)
+       win_ensure_size();
+
 #ifdef FEAT_CMDL_INFO
     need_flushbuf = add_to_showcmd(c);
 #endif
index 93264e1ad23df10c73e99be861cd9857b627182f..740d310b76092d889b0543666c174d33416e210a 100644 (file)
@@ -55,6 +55,7 @@ void shell_new_columns(void);
 void win_size_save(garray_T *gap);
 void win_size_restore(garray_T *gap);
 int win_comp_pos(void);
+void win_ensure_size(void);
 void win_setheight(int height);
 void win_setheight_win(int height, win_T *win);
 void win_setwidth(int width);
index af7c63a19cc709d0a605cfba8b140534dbf442a2..68c44a0c386802af922f52678a6871b9da124221 100644 (file)
@@ -1358,4 +1358,38 @@ func Test_close_dest_window()
   %bw!
 endfunc
 
+func Test_window_minimal_size()
+  set winminwidth=0 winminheight=0
+
+  " check size is fixed vertically
+  new
+  call win_execute(win_getid(2), 'wincmd _')
+  call assert_equal(0, winheight(0))
+  call feedkeys('0', 'tx')
+  call assert_equal(1, winheight(0))
+  bwipe!
+
+  " check size is fixed horizontally
+  vert new
+  call win_execute(win_getid(2), 'wincmd |')
+  call assert_equal(0, winwidth(0))
+  call feedkeys('0', 'tx')
+  call assert_equal(1, winwidth(0))
+  bwipe!
+
+  if has('timers')
+    " check size is fixed in Insert mode
+    new
+    call timer_start(100, {_ -> win_execute(win_getid(2), 'wincmd _')})
+    call timer_start(200, {_ -> assert_equal(0, winheight(0))})
+    call timer_start(300, {_ -> feedkeys(" \<Esc>", 't!')})
+    call feedkeys('a', 'tx!')
+    call assert_equal(1, winheight(0))
+    bwipe!
+  endif
+
+  set winminwidth& winminheight&
+endfunc
+
+
 " vim: shiftwidth=2 sts=2 expandtab
index a14f9a770fc17e6862b0fb706d03536a5c37ab1a..06b91839e8434b5fa7e832f06a5d6bd3f2b33bfe 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3764,
 /**/
     3763,
 /**/
index 47fb815972b9c744d2078c3f395407a15614c84c..b54813f4fffcfb5353e2b3bd3315a23782dfa133 100644 (file)
@@ -5517,6 +5517,18 @@ frame_comp_pos(frame_T *topfrp, int *row, int *col)
     }
 }
 
+/*
+ * Make the current window show at least one line and one column.
+ */
+    void
+win_ensure_size()
+{
+    if (curwin->w_height == 0)
+       win_setheight(1);
+    if (curwin->w_width == 0)
+       win_setwidth(1);
+}
+
 /*
  * Set current window height and take care of repositioning other windows to
  * fit around it.