changeset 2471:6570c136be32 vim73

Improvements for :find completion. (Nazri Ramliy)
author Bram Moolenaar <bram@vim.org>
date Mon, 02 Aug 2010 21:33:37 +0200
parents 481f808ab5e1
children 3567e0d56891
files src/misc1.c
diffstat 1 files changed, 52 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -9317,6 +9317,7 @@ expand_path_option(curdir, gap)
     char_u	*path_option = *curbuf->b_p_path == NUL
 						  ? p_path : curbuf->b_p_path;
     char_u	*buf;
+    char_u	*p;
 
     ga_init2(gap, (int)sizeof(char_u *), 1);
 
@@ -9350,7 +9351,12 @@ expand_path_option(curdir, gap)
 	    STRMOVE(buf + curdir_len, buf + curdir_len + 1);
 	}
 
-	addfile(gap, buf, EW_NOTFOUND|EW_DIR|EW_FILE);
+	if (ga_grow(gap, 1) == FAIL)
+	    break;
+	p = vim_strsave(buf);
+	if (p == NULL)
+	    break;
+	((char_u **)gap->ga_data)[gap->ga_len++] = p;
     }
 
     vim_free(buf);
@@ -9378,8 +9384,11 @@ get_path_cutoff(fname, gap)
     {
 	int j = 0;
 
-	while (fname[j] == path_part[i][j] && fname[j] != NUL
-						   && path_part[i][j] != NUL)
+	while ((fname[j] == path_part[i][j]
+#if defined(WIN3264)
+		|| (vim_ispathsep(fname[j]) && vim_ispathsep(path_part[i][j]))
+#endif
+			     ) && fname[j] != NUL && path_part[i][j] != NUL)
 	    j++;
 	if (j > maxlen)
 	{
@@ -9389,8 +9398,15 @@ get_path_cutoff(fname, gap)
     }
 
     /* Skip to the file or directory name */
-    while (cutoff != NULL && vim_ispathsep(*cutoff) && *cutoff != NUL)
-	mb_ptr_adv(cutoff);
+    if (cutoff != NULL)
+	while (
+#if defined(WIN3264)
+		*cutoff == '/'
+#else
+		vim_ispathsep(*cutoff)
+#endif
+	      )
+	    mb_ptr_adv(cutoff);
 
     return cutoff;
 }
@@ -9454,7 +9470,13 @@ uniquefy_paths(gap, pattern)
 	char_u	    *dir_end = gettail(path);
 
 	len = (int)STRLEN(path);
-	while (dir_end > path && !vim_ispathsep(*dir_end))
+	while (dir_end > path &&
+#if defined(WIN3264)
+		*dir_end != '/'
+#else
+		!vim_ispathsep(*dir_end)
+#endif
+		)
 	    mb_ptr_back(path, dir_end);
 	is_in_curdir = STRNCMP(curdir, path, dir_end - path) == 0
 					     && curdir[dir_end - path] == NUL;
@@ -9537,8 +9559,8 @@ theend:
 }
 
 /*
- * Calls globpath with 'path' values for the given pattern and stores
- * the result in gap.
+ * Calls globpath() or mch_expandpath() with 'path' values for the given
+ * pattern and stores the result in gap.
  * Returns the total number of matches.
  */
     static int
@@ -9547,15 +9569,18 @@ expand_in_path(gap, pattern, flags)
     char_u	*pattern;
     int		flags;		/* EW_* flags */
 {
-    int		c = 0;
+    char_u	**path_list;
+    char_u	*curdir;
+    garray_T	path_ga;
+    int		i;
+# ifdef WIN3264
+    char_u	*file_pattern;
+# else
     char_u	*files = NULL;
     char_u	*s;	/* start */
     char_u	*e;	/* end */
     char_u	*paths = NULL;
-    char_u	**path_list;
-    char_u	*curdir;
-    garray_T	path_ga;
-    int		i;
+# endif
 
     if ((curdir = alloc((int)(MAXPATHL))) == NULL)
 	return 0;
@@ -9564,6 +9589,17 @@ expand_in_path(gap, pattern, flags)
     expand_path_option(curdir, &path_ga);
     vim_free(curdir);
     path_list = (char_u **)(path_ga.ga_data);
+# ifdef WIN3264
+    for (i = 0; i < path_ga.ga_len; i++)
+    {
+	if (STRLEN(path_list[i]) + STRLEN(pattern) + 2 > MAXPATHL)
+	    continue;
+	STRCPY(file_pattern, path_list[i]);
+	STRCAT(file_pattern, "/");
+	STRCAT(file_pattern, pattern);
+	mch_expandpath(gap, file_pattern, EW_DIR|EW_ADDSLASH|EW_FILE);
+    }
+# else
     for (i = 0; i < path_ga.ga_len; i++)
     {
 	if (paths == NULL)
@@ -9609,10 +9645,10 @@ expand_in_path(gap, pattern, flags)
 	}
     }
 
-    c = gap->ga_len;
     vim_free(files);
-
-    return c;
+# endif
+
+    return gap->ga_len;
 }
 #endif