@@ -10514,18 +10514,34 @@ uniquefy_paths(garray_T *gap, char_u *pattern)
1051410514 /* Shorten the filename while maintaining its uniqueness */
1051510515 path_cutoff = get_path_cutoff (path , & path_ga );
1051610516
10517- /* we start at the end of the path */
10518- pathsep_p = path + len - 1 ;
10517+ /* Don't assume all files can be reached without path when search
10518+ * pattern starts with star star slash, so only remove path_cutoff
10519+ * when possible. */
10520+ if (pattern [0 ] == '*' && pattern [1 ] == '*'
10521+ && vim_ispathsep_nocolon (pattern [2 ])
10522+ && path_cutoff != NULL
10523+ && vim_regexec (& regmatch , path_cutoff , (colnr_T )0 )
10524+ && is_unique (path_cutoff , gap , i ))
10525+ {
10526+ sort_again = TRUE;
10527+ mch_memmove (path , path_cutoff , STRLEN (path_cutoff ) + 1 );
10528+ }
10529+ else
10530+ {
10531+ /* Here all files can be reached without path, so get shortest
10532+ * unique path. We start at the end of the path. */
10533+ pathsep_p = path + len - 1 ;
1051910534
10520- while (find_previous_pathsep (path , & pathsep_p ))
10521- if (vim_regexec (& regmatch , pathsep_p + 1 , (colnr_T )0 )
10522- && is_unique (pathsep_p + 1 , gap , i )
10523- && path_cutoff != NULL && pathsep_p + 1 >= path_cutoff )
10524- {
10525- sort_again = TRUE;
10526- mch_memmove (path , pathsep_p + 1 , STRLEN (pathsep_p ));
10527- break ;
10528- }
10535+ while (find_previous_pathsep (path , & pathsep_p ))
10536+ if (vim_regexec (& regmatch , pathsep_p + 1 , (colnr_T )0 )
10537+ && is_unique (pathsep_p + 1 , gap , i )
10538+ && path_cutoff != NULL && pathsep_p + 1 >= path_cutoff )
10539+ {
10540+ sort_again = TRUE;
10541+ mch_memmove (path , pathsep_p + 1 , STRLEN (pathsep_p ));
10542+ break ;
10543+ }
10544+ }
1052910545
1053010546 if (mch_isFullName (path ))
1053110547 {
0 commit comments