summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-08-28 13:02:45 +0100
committerBram Moolenaar <Bram@vim.org>2022-08-28 13:02:45 +0100
commit43568648dfefe5796dc3fe8fe711135eb20d9eb6 (patch)
tree59d27e3974535207bc9b21a32ec8dc777f40fd9c /src
parentb0509c542ed974cb388d49273d365ff2daf43159 (diff)
patch 9.0.0294: crash when 'cmdheight' is 0 and popup_clear() usedv9.0.0294
Problem: Crash when 'cmdheight' is 0 and popup_clear() used. Solution: Reset "message_win" when the message popup is cleared. Close the popup when 'cmdheight' is non-zero. Add a screendump test.
Diffstat (limited to 'src')
-rw-r--r--src/popupwin.c23
-rw-r--r--src/proto/popupwin.pro1
-rw-r--r--src/testdir/dumps/Test_cmdheight_zero_1.dump6
-rw-r--r--src/testdir/dumps/Test_cmdheight_zero_2.dump6
-rw-r--r--src/testdir/dumps/Test_cmdheight_zero_3.dump6
-rw-r--r--src/testdir/test_messages.vim28
-rw-r--r--src/version.c2
-rw-r--r--src/window.c5
8 files changed, 74 insertions, 3 deletions
diff --git a/src/popupwin.c b/src/popupwin.c
index 68ec64a2df..0cccf4ae83 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -28,6 +28,11 @@ static poppos_entry_T poppos_entries[] = {
{"center", POPPOS_CENTER}
};
+#ifdef HAS_MESSAGE_WINDOW
+// Window used for messages when 'winheight' is zero.
+static win_T *message_win = NULL;
+#endif
+
static void popup_adjust_position(win_T *wp);
/*
@@ -2770,6 +2775,11 @@ popup_free(win_T *wp)
clear_cmdline = TRUE;
win_free_popup(wp);
+#ifdef HAS_MESSAGE_WINDOW
+ if (wp == message_win)
+ message_win = NULL;
+#endif
+
redraw_all_later(UPD_NOT_VALID);
popup_mask_refresh = TRUE;
}
@@ -4440,9 +4450,6 @@ popup_close_info(void)
#if defined(HAS_MESSAGE_WINDOW) || defined(PROTO)
-// Window used for messages when 'winheight' is zero.
-static win_T *message_win = NULL;
-
/*
* Get the message window.
* Returns NULL if something failed.
@@ -4516,6 +4523,16 @@ popup_hide_message_win(void)
popup_hide(message_win);
}
+/*
+ * If the message window exists: close it.
+ */
+ void
+popup_close_message_win(void)
+{
+ if (message_win != NULL)
+ popup_close(message_win->w_id, TRUE);
+}
+
#endif
/*
diff --git a/src/proto/popupwin.pro b/src/proto/popupwin.pro
index ef769413c4..a12cb3eb29 100644
--- a/src/proto/popupwin.pro
+++ b/src/proto/popupwin.pro
@@ -66,6 +66,7 @@ win_T *popup_get_message_win(void);
void popup_show_message_win(void);
int popup_message_win_visible(void);
void popup_hide_message_win(void);
+void popup_close_message_win(void);
int popup_win_closed(win_T *win);
void popup_set_title(win_T *wp);
void popup_update_preview_title(void);
diff --git a/src/testdir/dumps/Test_cmdheight_zero_1.dump b/src/testdir/dumps/Test_cmdheight_zero_1.dump
new file mode 100644
index 0000000000..6fd15a07db
--- /dev/null
+++ b/src/testdir/dumps/Test_cmdheight_zero_1.dump
@@ -0,0 +1,6 @@
+>s+0&#ffffff0|o|m|e| |t|e|x|t| @65
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
diff --git a/src/testdir/dumps/Test_cmdheight_zero_2.dump b/src/testdir/dumps/Test_cmdheight_zero_2.dump
new file mode 100644
index 0000000000..d8c3aeafec
--- /dev/null
+++ b/src/testdir/dumps/Test_cmdheight_zero_2.dump
@@ -0,0 +1,6 @@
+|s+0&#e0e0e08|o|m|e| >t+0&#ffffff0|e|x|t| @65
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
diff --git a/src/testdir/dumps/Test_cmdheight_zero_3.dump b/src/testdir/dumps/Test_cmdheight_zero_3.dump
new file mode 100644
index 0000000000..ea83d3dccf
--- /dev/null
+++ b/src/testdir/dumps/Test_cmdheight_zero_3.dump
@@ -0,0 +1,6 @@
+|s+0&#ffffff0|o|m|e| >t|e|x|t| @65
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|═+0#e000002&@74
+|m|e|s@1|a|g|e| |w|i|n|d|o|w| @60
diff --git a/src/testdir/test_messages.vim b/src/testdir/test_messages.vim
index 00e942e7b1..ffb7a209ec 100644
--- a/src/testdir/test_messages.vim
+++ b/src/testdir/test_messages.vim
@@ -471,4 +471,32 @@ func Test_cmdheight_zero()
redraw
endfunc
+func Test_cmdheight_zero_dump()
+ CheckScreendump
+
+ let lines =<< trim END
+ set cmdheight=0
+ set showmode
+ call setline(1, 'some text')
+ END
+ call writefile(lines, 'XtestCmdheight')
+ let buf = RunVimInTerminal('-S XtestCmdheight', #{rows: 6})
+ " The "-- INSERT --" indicator should not be visible.
+ call term_sendkeys(buf, "i")
+ call VerifyScreenDump(buf, 'Test_cmdheight_zero_1', {})
+
+ " The "-- VISUAL --" indicator should not be visible.
+ call term_sendkeys(buf, "\<Esc>vw")
+ call VerifyScreenDump(buf, 'Test_cmdheight_zero_2', {})
+
+ " Echo'd text is in a popup window
+ call term_sendkeys(buf, "\<Esc>:echo 'message window'\<CR>")
+ call VerifyScreenDump(buf, 'Test_cmdheight_zero_3', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('XtestCmdheight')
+endfunc
+
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index b25ed44f53..afb61e0b3f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -708,6 +708,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 294,
+/**/
293,
/**/
292,
diff --git a/src/window.c b/src/window.c
index 8c42b6064a..7c5c7ff69c 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6603,6 +6603,11 @@ command_height(void)
// Recompute window positions.
if (frp != lastwin->w_frame)
(void)win_comp_pos();
+
+#ifdef HAS_MESSAGE_WINDOW
+ if (p_ch > 0)
+ popup_close_message_win();
+#endif
}
/*