]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1338: Calling expand() interferes with cmdcomplete_info() v9.1.1338
authorzeertzjq <zeertzjq@outlook.com>
Wed, 23 Apr 2025 18:50:23 +0000 (20:50 +0200)
committerChristian Brabandt <cb@256bit.org>
Wed, 23 Apr 2025 18:50:23 +0000 (20:50 +0200)
Problem:  Calling expand() interferes with cmdcomplete_info()
          (after 9.1.1329).
Solution: Only clear cmdline_orig when starting/ending cmdline mode
          (zeertzjq).

closes: #17192

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/cmdexpand.c
src/ex_getln.c
src/proto/cmdexpand.pro
src/testdir/test_cmdline.vim
src/version.c

index e8bc0805ca59661585f89be62967f087e3a79020..4dbd10ee8a7ab4e6871ce6d8a1cb88f0e3787e92 100644 (file)
@@ -1115,7 +1115,6 @@ ExpandInit(expand_T *xp)
     xp->xp_backslash = XP_BS_NONE;
     xp->xp_prefix = XP_PREFIX_NONE;
     xp->xp_numfiles = -1;
-    VIM_CLEAR(cmdline_orig);
 }
 
 /*
@@ -1132,6 +1131,12 @@ ExpandCleanup(expand_T *xp)
     VIM_CLEAR(xp->xp_orig);
 }
 
+    void
+clear_cmdline_orig(void)
+{
+    VIM_CLEAR(cmdline_orig);
+}
+
 /*
  * Display one line of completion matches. Multiple matches are displayed in
  * each line (used by wildmode=list and CTRL-D)
index 8445236acc77bbaa93ea7aafa6b9bb954ddd789d..1be5a0c1f63cfb97100b415cc449d7929c59e7a8 100644 (file)
@@ -1663,6 +1663,7 @@ getcmdline_int(
 
     ExpandInit(&xpc);
     ccline.xpc = &xpc;
+    clear_cmdline_orig();
 
 #ifdef FEAT_RIGHTLEFT
     if (curwin->w_p_rl && *curwin->w_p_rlc == 's'
@@ -2567,6 +2568,7 @@ returncmd:
 
     ExpandCleanup(&xpc);
     ccline.xpc = NULL;
+    clear_cmdline_orig();
 
 #ifdef FEAT_SEARCH_EXTRA
     finish_incsearch_highlighting(gotesc, &is_state, FALSE);
index 73db378bf99f4de4b830c913f3fe21bb1da5798f..92e9dcb02493098d3cd7f349a003b31ad950669b 100644 (file)
@@ -11,6 +11,7 @@ int cmdline_compl_is_fuzzy(void);
 char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode);
 void ExpandInit(expand_T *xp);
 void ExpandCleanup(expand_T *xp);
+void clear_cmdline_orig(void);
 int showmatches(expand_T *xp, int wildmenu);
 char_u *addstar(char_u *fname, int len, int context);
 void set_expand_context(expand_T *xp);
index 364909cc50b1663351d3eeef415d2e648597f579..c66a4273e327d72950362982f25ddd83033915ba 100644 (file)
@@ -4268,10 +4268,12 @@ func Test_cd_bslash_completion_windows()
   let &shellslash = save_shellslash
 endfunc
 
-" Testg cmdcomplete_info() with CmdlineLeavePre autocmd
+" Test cmdcomplete_info() with CmdlineLeavePre autocmd
 func Test_cmdcomplete_info()
   augroup test_CmdlineLeavePre
     autocmd!
+    " Calling expand() should not interfere with cmdcomplete_info().
+    autocmd CmdlineLeavePre * call expand('test_cmdline.*')
     autocmd CmdlineLeavePre * let g:cmdcomplete_info = string(cmdcomplete_info())
   augroup END
   new
index fec0e0d1862bd08f0390b8888c2b516b507043f8..e9dc252ea3014f1b49cacbd28c43760e180b44d5 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1338,
 /**/
     1337,
 /**/