On Thu, Aug 5, 2010 at 4:11 AM, Bram Moolenaar <[email protected]> wrote:
>> > I noticed another problem: with 'path' set to "./**" and in an empty
>> > buffer :find completion crashes. =A0I fixed it.
>>
>> Thanks. I'll add this check to the test script.
I've updated the test to check for this and a few more conditions.
> The test script works OK on Unix, but on MS-Windows it only finds two of
> the three files. Also interactively, so this appears to be a problem in
> the implementation.
Attached patch 0002 fixes this issue.
> I already changed it to use three separate "mkdir" commands, as "mkdir
> -p" doesn't work on MS-Windows (and some old Unixen too).
The "mkdir Xfind/in" gives error on windows, it should be "mkdir
Xfind\in". I've modified it to work on both unix and windows in patch
0003.
>
> I used an edit command instead of ":!echo" to make it portable.
>
> What I can't figure out is a portable way to delete the created
> directories. "rmdir /s /q Xfind" should work, but it gives an error for
> the /s option...
Patch 0003 checks the platform using has("win??") and runs the
appropriate command.
Patch 0001 moves the check for path_with_url() for skipping urls during
find completion from globpath() into expand_path_option(). That is the
correct place to make the call for excluding any non-supported path for
find completion.
test73.in should now run successfully on both unix and windows.
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 fc8868bfedaf9551f6274d3946790d06b2ec0364 Mon Sep 17 00:00:00 2001
From: Nazri Ramliy <[email protected]>
Date: Thu, 5 Aug 2010 09:59:04 +0800
Subject: [PATCH 1/3] find completion: Path url should be skipped earlier.
Doing it in globpath() is too late and not appropriate.
---
src/ex_getln.c | 6 ------
src/misc1.c | 2 ++
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 790d531..948e59a 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -5045,12 +5045,6 @@ globpath(path, file, expand_options)
{
/* Copy one item of the path to buf[] and concatenate the file name. */
copy_option_part(&path, buf, MAXPATHL, ",");
- if (path_with_url(buf))
- continue;
- /*
- * FIXME: should we proactively skip 'path' with limiter (/usr/ **N)
- * and upward search (;) notations, just like we did with url above?
- */
if (STRLEN(buf) + STRLEN(file) + 2 < MAXPATHL)
{
add_pathsep(buf);
diff --git a/src/misc1.c b/src/misc1.c
index c8fb8eb..ef7c10c 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -9337,6 +9337,8 @@ expand_path_option(curdir, gap)
}
else if (buf[0] == NUL) /* relative to current directory */
STRCPY(buf, curdir);
+ else if (path_with_url(buf))
+ continue;
else if (!mch_isFullName(buf))
{
/* Expand relative path to their full path equivalent */
--
1.7.2.1.6.g61bf12
From 116422ea986dc2bb568c0b943c6fa5460999e61e Mon Sep 17 00:00:00 2001
From: Nazri Ramliy <[email protected]>
Date: Thu, 5 Aug 2010 12:32:02 +0800
Subject: [PATCH 2/3] find completion on windows: use / as path separator when joining path
---
src/ex_getln.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 948e59a..0c48fe8 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -5047,7 +5047,16 @@ globpath(path, file, expand_options)
copy_option_part(&path, buf, MAXPATHL, ",");
if (STRLEN(buf) + STRLEN(file) + 2 < MAXPATHL)
{
+#ifdef WIN3264
+ /*
+ * Using the platform's path separator (\) makes vim incorrectly
+ * treat it as an escape character, use '/' instead.
+ * TODO: Add it only if there is none yet, like add_pathsep does.
+ */
+ STRCAT(buf, "/");
+#else
add_pathsep(buf);
+#endif
STRCAT(buf, file);
if (ExpandFromContext(&xpc, buf, &num_p, &p,
WILD_SILENT|expand_options) != FAIL && num_p > 0)
--
1.7.2.1.6.g61bf12
From e3cba918c80dda9f7ee2c05c08980d4462de368f Mon Sep 17 00:00:00 2001
From: Nazri Ramliy <[email protected]>
Date: Thu, 5 Aug 2010 13:50:41 +0800
Subject: [PATCH 3/3] Add more tests to find completion (test73.in)
---
src/testdir/test73.in | 81 ++++++++++++++++++++++++++++++++++++++++++++++--
src/testdir/test73.ok | 8 +++++
2 files changed, 85 insertions(+), 4 deletions(-)
diff --git a/src/testdir/test73.in b/src/testdir/test73.in
index 8928aeb..c9684a3 100644
--- a/src/testdir/test73.in
+++ b/src/testdir/test73.in
@@ -1,23 +1,96 @@
Tests for find completion.
STARTTEST
+:" Do all test in a separate window to avoid E211 when we recursively
+:" delete the Xfind directory during cleanup
+
+:function! DeleteDirectory(dir)
+: if has("win32") || has("win95") || has("win64") || has("win16")
+: exec "silent !rmdir /Q /S " . a:dir
+: else
+: exec "silent !rm -rf " . a:dir
+: endif
+:endfun
+:" On windows a stale "Xfind" directory may exist, remove it so that
+:" we start from a clean state.
+:call DeleteDirectory("Xfind")
+:set nocp
+:new
+:let cwd=getcwd()
:!mkdir Xfind
-:!mkdir Xfind/in
-:!mkdir Xfind/in/path
+:cd Xfind
+:set path=
+:find
+:w! ../test.out
+:close
+:new
+:set path=.
+:find
+:w >>../test.out
+:close
+:new
+:set path=.,,
+:find
+:w >>../test.out
+:close
+:new
+:set path=./**
+:find
+:w >>../test.out
+:close
+:new
+:" We shouldn't find any file at this point, ../test.out must be empty.
+:!mkdir in
+:cd in
+:!mkdir path
+:exec "cd " . cwd
:e Xfind/file.txt
SHoly Grail:w
:e Xfind/in/file.txt
SJimmy Hoffa:w
+:e Xfind/in/stuff.txt
+SAnother Holy Grail:w
:e Xfind/in/path/file.txt
SE.T.:w
:set path=Xfind/**
-:set nocp
:find file
-:w! test.out
+:w >> test.out
+:find file
+:w >>test.out
+:find file
+:w >>test.out
+:" Rerun the previous three find completions, using fullpath in 'path'
+:exec "set path=" . cwd . "/Xfind/**"
+:find file
+:w >> test.out
:find file
:w >>test.out
:find file
:w >>test.out
+:" Same steps again, using relative and fullpath items that point to the same
+:" recursive location.
+:" This is to test that there are no duplicates in the completion list.
+:exec "set path+=Xfind/**"
+:find file
+:w >> test.out
+:find file
+:w >>test.out
+:find file
+:w >>test.out
+:find file
+:" Test find completion for directory of current buffer, which at this point
+:" is Xfind/in/file.txt.
+:set path=.
+:find st
+:w >> test.out
+:" Test find completion for empty path item ",," which is the current directory
+:cd Xfind
+:set path=,,
+:find f
+:w >> ../test.out
+:"cd ..
+:q
+:call DeleteDirectory("Xfind")
:qa!
ENDTEST
diff --git a/src/testdir/test73.ok b/src/testdir/test73.ok
index bf1d433..cd787f2 100644
--- a/src/testdir/test73.ok
+++ b/src/testdir/test73.ok
@@ -1,3 +1,11 @@
Holy Grail
Jimmy Hoffa
E.T.
+Holy Grail
+Jimmy Hoffa
+E.T.
+Holy Grail
+Jimmy Hoffa
+E.T.
+Another Holy Grail
+Holy Grail
--
1.7.2.1.6.g61bf12