summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/todo.txt2
-rw-r--r--src/misc1.c54
2 files changed, 35 insertions, 21 deletions
diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index 1dabb75f..a77f6849 100644
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -32,8 +32,6 @@ be worked on, but only if you sponsor Vim development. See |sponsor|.
GTK: torn-off menu doesn't work.
-:find completion has duplicates. (Bjorn Winckler, 2010 Jul 18)
-
Cursor positioning wrong with 0x200e character. (John Becket, 2010 May 6)
Test 69 breaks on MS-Windows, both 32 and 64 builds. (George Reilly, 2010 Feb
diff --git a/src/misc1.c b/src/misc1.c
index cd5ae4b2..8e2c656e 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -9236,6 +9236,7 @@ unix_expandpath(gap, path, wildoff, flags, didstar)
#if defined(FEAT_SEARCHPATH)
static int find_previous_pathsep __ARGS((char_u *path, char_u **psep));
static int is_unique __ARGS((char_u *maybe_unique, garray_T *gap, int i));
+static void remove_duplicates __ARGS((garray_T *gap));
static void uniquefy_paths __ARGS((garray_T *gap, char_u *pattern));
static int expand_in_path __ARGS((garray_T *gap, char_u *pattern, int flags));
@@ -9305,38 +9306,50 @@ is_unique(maybe_unique, gap, i)
}
/*
- * Sorts, removes duplicates and modifies all the fullpath names in gap so that
- * they are unique with respect to each other while conserving the part that
- * matches the pattern. Beware, this is at least O(n^2) wrt gap->ga_len.
+ * Remove adjecent duplicate entries from "gap", which is a list of file names
+ * in allocated memory.
*/
static void
-uniquefy_paths(gap, pattern)
+remove_duplicates(gap)
garray_T *gap;
- char_u *pattern;
{
int i;
int j;
- int len;
- char_u *pathsep_p;
- char_u *path;
- char_u **fnames = (char_u **) gap->ga_data;
+ char_u **fnames = (char_u **)gap->ga_data;
+
+ for (i = 1; i < gap->ga_len; ++i)
+ if (fnamecmp(fnames[i - 1], fnames[i]) == 0)
+ {
+ vim_free(fnames[i]);
+ for (j = i + 1; j < gap->ga_len; ++j)
+ fnames[j - 1] = fnames[j];
+ --gap->ga_len;
+ --i;
+ }
+}
+/*
+ * Sorts, removes duplicates and modifies all the fullpath names in gap so that
+ * they are unique with respect to each other while conserving the part that
+ * matches the pattern. Beware, this is at least O(n^2) wrt gap->ga_len.
+ */
+ static void
+uniquefy_paths(gap, pattern)
+ garray_T *gap;
+ char_u *pattern;
+{
+ int i;
+ int len;
+ char_u *pathsep_p;
+ char_u *path;
+ char_u **fnames = (char_u **) gap->ga_data;
int sort_again = 0;
char_u *pat;
char_u *file_pattern;
regmatch_T regmatch;
- /* Remove duplicate entries */
sort_strings(fnames, gap->ga_len);
- for (i = 0; i < gap->ga_len - 1; i++)
- if (fnamecmp(fnames[i], fnames[i+1]) == 0)
- {
- vim_free(fnames[i]);
- for (j = i+1; j < gap->ga_len; j++)
- fnames[j-1] = fnames[j];
- gap->ga_len--;
- i--;
- }
+ remove_duplicates(gap);
/*
* We need to prepend a '*' at the beginning of file_pattern so that the
@@ -9379,7 +9392,10 @@ uniquefy_paths(gap, pattern)
}
if (sort_again)
+ {
sort_strings(fnames, gap->ga_len);
+ remove_duplicates(gap);
+ }
}
/*