]> granicus.if.org Git - vim/commitdiff
patch 8.1.2108: cannot close the cmdline window from CmdWinEnter v8.1.2108
authorBram Moolenaar <Bram@vim.org>
Tue, 1 Oct 2019 15:39:04 +0000 (17:39 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 1 Oct 2019 15:39:04 +0000 (17:39 +0200)
Problem:    Cannot close the cmdline window from CmdWinEnter. (George Brown)
Solution:   Reset cmdwin_result earlier. (Christian Brabandt, closes #4980)

src/ex_getln.c
src/testdir/test_autocmd.vim
src/version.c

index ef8e387b70d927fb7b69d3f75071a263507f0a45..ef87413b7cf028697effcf3976ac15b7d7f3b7a1 100644 (file)
@@ -136,11 +136,11 @@ restore_viewstate(viewstate_T *vs)
 // Struct to store the state of 'incsearch' highlighting.
 typedef struct {
     pos_T      search_start;   // where 'incsearch' starts searching
-    pos_T       save_cursor;
+    pos_T      save_cursor;
     viewstate_T        init_viewstate;
     viewstate_T        old_viewstate;
-    pos_T       match_start;
-    pos_T       match_end;
+    pos_T      match_start;
+    pos_T      match_end;
     int                did_incsearch;
     int                incsearch_postponed;
     int                magic_save;
@@ -4152,12 +4152,15 @@ open_cmdwin(void)
     invalidate_botline();
     redraw_later(SOME_VALID);
 
-    /* No Ex mode here! */
+    // No Ex mode here!
     exmode_active = 0;
 
     State = NORMAL;
     setmouse();
 
+    // Reset here so it can be set by a CmdWinEnter autocommand.
+    cmdwin_result = 0;
+
     // Trigger CmdwinEnter autocommands.
     trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINENTER);
     if (restart_edit != 0)     // autocmd with ":startinsert"
@@ -4169,7 +4172,6 @@ open_cmdwin(void)
     /*
      * Call the main loop until <CR> or CTRL-C is typed.
      */
-    cmdwin_result = 0;
     main_loop(TRUE, FALSE);
 
     RedrawingDisabled = i;
index f2c9af50f872655c576049a16e07c63d54a33e4c..fe77bf578667bc0b57d13a1f915aaf4961e848ee 100644 (file)
@@ -2259,3 +2259,32 @@ func Test_autocmd_SafeState()
   call StopVimInTerminal(buf)
   call delete('XSafeState')
 endfunc
+
+func Test_autocmd_CmdWinEnter()
+  CheckRunVimInTerminal
+  " There is not cmdwin switch, so
+  " test for cmdline_hist
+  " (both are available with small builds)
+  CheckFeature cmdline_hist
+  let lines =<< trim END
+    let b:dummy_var = 'This is a dummy'
+    autocmd CmdWinEnter * quit
+    let winnr = winnr('$')
+  END
+  let filename='XCmdWinEnter'
+  call writefile(lines, filename)
+  let buf = RunVimInTerminal('-S '.filename, #{rows: 6})
+
+  call term_sendkeys(buf, "q:")
+  call term_wait(buf)
+  call term_sendkeys(buf, ":echo b:dummy_var\<cr>")
+  call WaitForAssert({-> assert_match('^This is a dummy', term_getline(buf, 6))}, 1000)
+  call term_sendkeys(buf, ":echo &buftype\<cr>")
+  call WaitForAssert({-> assert_notmatch('^nofile', term_getline(buf, 6))}, 1000)
+  call term_sendkeys(buf, ":echo winnr\<cr>")
+  call WaitForAssert({-> assert_match('^1', term_getline(buf, 6))}, 1000)
+
+  " clean up
+  call StopVimInTerminal(buf)
+  call delete(filename)
+endfunc
index e2f0c92008feb600a47fe2873626cd77c0b8ef2f..469b759b673e3b222e69cbf8451cb13a6a2c32a7 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2108,
 /**/
     2107,
 /**/