changeset 10002:ff0b4216f026 v7.4.2274

commit https://github.com/vim/vim/commit/73d4e4c8922f6f4d256f910a18f47c0c3a48c28b Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 27 21:55:13 2016 +0200 patch 7.4.2274 Problem: Command line completion on "find **/filename" drops sub-directory. Solution: Handle this case separately. (Harm te Hennepe, closes https://github.com/vim/vim/issues/932, closes https://github.com/vim/vim/issues/939)
author Christian Brabandt <cb@256bit.org>
date Sat, 27 Aug 2016 22:00:07 +0200
parents 7b64e4c76677
children 3aa9bc9ddcbe
files src/misc1.c src/testdir/test_cmdline.vim src/version.c
diffstat 3 files changed, 38 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -10514,18 +10514,34 @@ uniquefy_paths(garray_T *gap, char_u *pa
 	/* Shorten the filename while maintaining its uniqueness */
 	path_cutoff = get_path_cutoff(path, &path_ga);
 
-	/* we start at the end of the path */
-	pathsep_p = path + len - 1;
-
-	while (find_previous_pathsep(path, &pathsep_p))
-	    if (vim_regexec(&regmatch, pathsep_p + 1, (colnr_T)0)
-		    && is_unique(pathsep_p + 1, gap, i)
-		    && path_cutoff != NULL && pathsep_p + 1 >= path_cutoff)
-	    {
-		sort_again = TRUE;
-		mch_memmove(path, pathsep_p + 1, STRLEN(pathsep_p));
-		break;
-	    }
+	/* Don't assume all files can be reached without path when search
+	 * pattern starts with star star slash, so only remove path_cutoff
+	 * when possible. */
+	if (pattern[0] == '*' && pattern[1] == '*'
+		&& vim_ispathsep_nocolon(pattern[2])
+		&& path_cutoff != NULL
+		&& vim_regexec(&regmatch, path_cutoff, (colnr_T)0)
+		&& is_unique(path_cutoff, gap, i))
+	{
+	    sort_again = TRUE;
+	    mch_memmove(path, path_cutoff, STRLEN(path_cutoff) + 1);
+	}
+	else
+	{
+	    /* Here all files can be reached without path, so get shortest
+	     * unique path.  We start at the end of the path. */
+	    pathsep_p = path + len - 1;
+
+	    while (find_previous_pathsep(path, &pathsep_p))
+		if (vim_regexec(&regmatch, pathsep_p + 1, (colnr_T)0)
+			&& is_unique(pathsep_p + 1, gap, i)
+			&& path_cutoff != NULL && pathsep_p + 1 >= path_cutoff)
+		{
+		    sort_again = TRUE;
+		    mch_memmove(path, pathsep_p + 1, STRLEN(pathsep_p));
+		    break;
+		}
+	}
 
 	if (mch_isFullName(path))
 	{
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -180,3 +180,11 @@ func Test_getcompletion()
 
   call assert_fails('call getcompletion("", "burp")', 'E475:')
 endfunc
+
+func Test_expand_star_star()
+  call mkdir('a/b', 'p')
+  call writefile(['asdfasdf'], 'a/b/fileXname')
+  call feedkeys(":find **/fileXname\<Tab>\<CR>", 'xt')
+  call assert_equal('find a/b/fileXname', getreg(':'))
+  call delete('a', 'rf')
+endfunc
--- a/src/version.c
+++ b/src/version.c
@@ -764,6 +764,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2274,
+/**/
     2273,
 /**/
     2272,