summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-12-09 11:57:22 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-09 11:57:22 +0000
commitd0fb907253a5c5a71b1f231f3ddec24098fb4e21 (patch)
tree5957d69d481db90e71e7e97c0c7a9497cc65072b
parente50507126f532a0b0ae65e201a6372b7ea5b0ccd (diff)
downloadvim-git-d0fb907253a5c5a71b1f231f3ddec24098fb4e21.tar.gz
patch 8.2.3764: cannot see any text when window was made zero linesv8.2.3764
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)
-rw-r--r--src/edit.c5
-rw-r--r--src/normal.c5
-rw-r--r--src/proto/window.pro1
-rw-r--r--src/testdir/test_window_cmd.vim34
-rw-r--r--src/version.c2
-rw-r--r--src/window.c12
6 files changed, 59 insertions, 0 deletions
diff --git a/src/edit.c b/src/edit.c
index 686c6d429..8dd60941a 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -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
diff --git a/src/normal.c b/src/normal.c
index 0fbfe9207..d3c4c7875 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -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
diff --git a/src/proto/window.pro b/src/proto/window.pro
index 93264e1ad..740d310b7 100644
--- a/src/proto/window.pro
+++ b/src/proto/window.pro
@@ -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);
diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim
index af7c63a19..68c44a0c3 100644
--- a/src/testdir/test_window_cmd.vim
+++ b/src/testdir/test_window_cmd.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index a14f9a770..06b91839e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3764,
+/**/
3763,
/**/
3762,
diff --git a/src/window.c b/src/window.c
index 47fb81597..b54813f4f 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5518,6 +5518,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.
*/