On Tue, Jul 20, 2010 at 8:06 AM, Nazri Ramliy <[email protected]> wrote:
> On Tue, Jul 20, 2010 at 12:47 AM, björn <[email protected]> wrote:
>> Oh, I didn't realize that.  Well, I can confirm that ":fin" behaves
>> identical to ":tabf" (duplicate entries).
>
> I can reproduce the duplicate entries.
>
> I'll look into this.

Attached patch solves the duplicate entry.

While fixing this bug I found another:

If you have these files:

$HOME/a/Makefile
$HOME/a/b/Makefile

and your path is set to '$HOME/a/**',
and your CWD is $HOME/a,

doing :find Make<tab>

will show "a/Makefile" (correct) and "b/Makefile" (WRONG) as the
possible completions.

"b/Makefile" should really be "Makefile".

The function uniquefy_paths in misc1.c shortens the list of full path
file names without taking into account the values in 'path' option.

I'll look into fixing this too.

nazri.

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
From 820753071dc4b8e9df479a5a97b86c0a85c647e4 Mon Sep 17 00:00:00 2001
From: nazri <[email protected]>
Date: Tue, 20 Jul 2010 12:14:00 +0800
Subject: [PATCH] find/sfind/tabfind completion: Always remove duplicate after sorting

---
 src/misc1.c |   35 ++++++++++++++++++++++++-----------
 1 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/src/misc1.c b/src/misc1.c
index cd5ae4b..d9f3942 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_duplicate __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));
 
@@ -9304,6 +9305,25 @@ is_unique(maybe_unique, gap, i)
     return TRUE;
 }
 
+    static void
+remove_duplicate(gap)
+    garray_T *gap;
+{
+    int	    i;
+    int	    j;
+    char_u  **fnames = (char_u **) gap->ga_data;
+
+    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--;
+	}
+}
+
 /*
  * 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
@@ -9315,7 +9335,6 @@ uniquefy_paths(gap, pattern)
     char_u *pattern;
 {
     int	    i;
-    int	    j;
     int	    len;
     char_u  *pathsep_p;
     char_u  *path;
@@ -9326,17 +9345,8 @@ uniquefy_paths(gap, pattern)
     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_duplicate(gap);
 
     /*
      * We need to prepend a '*' at the beginning of file_pattern so that the
@@ -9379,7 +9389,10 @@ uniquefy_paths(gap, pattern)
     }
 
     if (sort_again)
+    {
 	sort_strings(fnames, gap->ga_len);
+	remove_duplicate(gap);
+    }
 }
 
 /*
-- 
1.7.2.rc3.43.g24e7a

Raspunde prin e-mail lui