]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0790: 'completeslash' breaks :find completion with 'findfunc' v9.2.0790
authorglepnir <glephunter@gmail.com>
Sat, 18 Jul 2026 09:50:11 +0000 (09:50 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 18 Jul 2026 09:50:11 +0000 (09:50 +0000)
Problem:  On MS-Windows with 'completeslash' set, an item completed by
          'findfunc' cannot be opened with :find, E345 is given (Mao-Yining)
Solution: Do not apply 'completeslash' to matches returned by 'findfunc',
          they are opaque strings that are passed back to the function
          unchanged (glepnir)

fixes:  #20770
closes: #20771

Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/cmdexpand.c
src/testdir/test_findfile.vim
src/version.c

index bedcfdf368e5f45ef63b197f149f3a49f6d34b1e..97829937583f88d8ed553800f9b9211ba8ca7765 100644 (file)
@@ -3346,7 +3346,9 @@ expand_files_and_dirs(
     if (free_pat)
        vim_free(pat);
 #ifdef BACKSLASH_IN_FILENAME
-    if (p_csl[0] != NUL && (options & WILD_IGNORE_COMPLETESLASH) == 0)
+    if (p_csl[0] != NUL
+           && (options & WILD_IGNORE_COMPLETESLASH) == 0
+           && xp->xp_context != EXPAND_FINDFUNC)
     {
        int j;
 
index a5f1f6fdd42569513810643620dd3789619fc34e..3de2463febf0cf1c72f7f15ce7302c596a4946d4 100644 (file)
@@ -898,4 +898,29 @@ func Test_path_env_variable_with_whitespaces()
     enew
 endfunc
 
+func Test_findfunc_completeslash()
+  CheckMSWindows
+
+  func FindBsl(pat, cmdarg)
+    return ['Xdir\foo.c']->matchfuzzy(a:pat)
+  endfunc
+  func FindFwd(pat, cmdarg)
+    return ['Xdir/foo.c']->matchfuzzy(a:pat)
+  endfunc
+
+  set findfunc=FindBsl
+  set completeslash=slash
+  call feedkeys(":find Xdir\<C-A>\<C-B>\"\<CR>", 'tx')
+  call assert_equal('"find Xdir\foo.c', @:)
+
+  set findfunc=FindFwd
+  set completeslash=backslash
+  call feedkeys(":find Xdir\<C-A>\<C-B>\"\<CR>", 'tx')
+  call assert_equal('"find Xdir/foo.c', @:)
+
+  set completeslash& findfunc&
+  delfunc FindBsl
+  delfunc FindFwd
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 86904555a277727dd6fbf47a51f196bfeb42b0a2..f9abe4fa15daefcf5566a7ddaa73b8a8aaf20139 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    790,
 /**/
     789,
 /**/