changeset 24739:68e3adbeaf20 v8.2.2908

patch 8.2.2908: crash when using a terminal popup window from cmdline window Commit: https://github.com/vim/vim/commit/e5b4486c4279a9674a9bb76130b4db53fb9303a0 Author: Bram Moolenaar <Bram@vim.org> Date: Sun May 30 13:54:03 2021 +0200 patch 8.2.2908: crash when using a terminal popup window from cmdline window Problem: Crash when using a terminal popup window from the cmdline window. Solution: Instead of checking cmdwin_type call cmdwin_is_active(). (closes #8286)
author Bram Moolenaar <Bram@vim.org>
date Sun, 30 May 2021 14:00:05 +0200
parents cd3c2a881ff2
children 4b5cdb0e64ab
files src/errors.h src/terminal.c src/testdir/dumps/Test_cmdwin_no_terminal.dump src/testdir/test_cmdline.vim src/version.c
diffstat 5 files changed, 37 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/errors.h
+++ b/src/errors.h
@@ -415,3 +415,5 @@ EXTERN char e_expression_does_not_result
 	INIT(= N_("E1186: Expression does not result in a value: %s"));
 EXTERN char e_failed_to_source_defaults[]
 	INIT(= N_("E1187: Failed to source defaults.vim"));
+EXTERN char e_cannot_open_terminal_from_command_line_window[]
+	INIT(= N_("E1188: Cannot open a terminal from the command line window"));
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -445,6 +445,13 @@ term_start(
 
     if (check_restricted() || check_secure())
 	return NULL;
+#ifdef FEAT_CMDWIN
+    if (cmdwin_type != 0)
+    {
+	emsg(_(e_cannot_open_terminal_from_command_line_window));
+	return NULL;
+    }
+#endif
 
     if ((opt->jo_set & (JO_IN_IO + JO_OUT_IO + JO_ERR_IO))
 					 == (JO_IN_IO + JO_OUT_IO + JO_ERR_IO)
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_cmdwin_no_terminal.dump
@@ -0,0 +1,12 @@
+| +0&#ffffff0@74
+|[+1&&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
+|:+0#4040ff13&|s+0#af5f00255&|e|t| +0#0000000&|c+0#e000e06&|m|d|h|e|i|g|h|t|=+0#0000000&|2| @58
+|:+0#4040ff13&> +0#0000000&@73
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|[+3#0000000&|C|o|m@1|a|n|d| |L|i|n|e|]| @42|2|,|0|-|1| @9|A|l@1
+|E+0#ffffff16#e000002|1@1|8@1|:| |C|a|n@1|o|t| |o|p|e|n| |a| |t|e|r|m|i|n|a|l| |f|r|o|m| |t|h|e| |c|o|m@1|a|n|d| |l|i|n|e| |w|i|n|d|o|w| +0#0000000#ffffff0@16
+@75
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -1192,6 +1192,20 @@ func Test_cmdwin_restore()
   call delete('XTest_restore')
 endfunc
 
+func Test_cmdwin_no_terminal()
+  CheckFeature cmdwin
+  CheckFeature terminal
+
+  let buf = RunVimInTerminal('', {'rows': 12})
+  call TermWait(buf, 50)
+  call term_sendkeys(buf, ":set cmdheight=2\<CR>")
+  call term_sendkeys(buf, "q:")
+  call term_sendkeys(buf, ":let buf = term_start(['/bin/echo'], #{hidden: 1})\<CR>")
+  call VerifyScreenDump(buf, 'Test_cmdwin_no_terminal', {})
+  call term_sendkeys(buf, ":q\<CR>")
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_buffers_lastused()
   " check that buffers are sorted by time when wildmode has lastused
   call test_settime(1550020000)	  " middle
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2908,
+/**/
     2907,
 /**/
     2906,