diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-08-27 21:55:13 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-08-27 21:55:13 +0200 |
commit | 73d4e4c8922f6f4d256f910a18f47c0c3a48c28b (patch) | |
tree | 61f174d30ce316a317650c55140c2839da316426 /src/misc1.c | |
parent | 3056735ae8a366aa7fcb51872520895251858637 (diff) | |
download | vim-git-73d4e4c8922f6f4d256f910a18f47c0c3a48c28b.tar.gz |
patch 7.4.2274v7.4.2274
Problem: Command line completion on "find **/filename" drops sub-directory.
Solution: Handle this case separately. (Harm te Hennepe, closes #932, closes
#939)
Diffstat (limited to 'src/misc1.c')
-rw-r--r-- | src/misc1.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/misc1.c b/src/misc1.c index 8cb3b6fd9..d9f02b7bb 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -10514,18 +10514,34 @@ uniquefy_paths(garray_T *gap, char_u *pattern) /* 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; + /* 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(®match, 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(®match, 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; - } + while (find_previous_pathsep(path, &pathsep_p)) + if (vim_regexec(®match, 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)) { |