Hi

Ex command line completion is inconsistent with what Ex commands
expect when file to complete contains a % character.

Example:

$ cd /tmp
$ echo 123 > 111%222%333
$ echo 145 > 111%444%555

$ vim -u NONE --noplugin -N -c 'set wildmode=longest,list'

:e 11<Tab>      completes to:      :e 111\%              (OK)
:e 111\%2<Tab>  -----> E71: Invalid character after \%   (Not OK!)
:e 111%2<Tab>   completes to:      :e 111\%222\%333
:e 111\%222\%333<CR>  --> opens the file 111%222%333     (OK)

So for <Tab> completion to work, the % characters must not be
preceded with backslash.  However, completion itself adds the
backslashes in from of %.  It's inconsistent.  The Ex command
itself expects the backslash in front of % since % has a special
meaning in Ex commands (:help c_%):

I think that the correct behavior for completion should be:

:e 111\%2<Tab>   completes to:     e: 111\%222\%333

Attached patch makes it work that way, but please review it.
I only tested on Linux.

I noticed this bug since I have 'set undodir=~/UNDO' in my ~/.vimc.
The ~/UNDO/ dir contains several file names with this % character and
trying to use  <Tab> completion :e ~/UNDO/<Tab>  in that directory
does not work well.

Regards
-- Dominique

-- 
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
diff -r 60da25e3aab7 src/fileio.c
--- a/src/fileio.c	Mon May 31 21:59:46 2010 +0200
+++ b/src/fileio.c	Tue Jun 01 00:28:25 2010 +0200
@@ -10167,6 +10167,13 @@
 	    case '\\':
 		if (p[1] == NUL)
 		    break;
+		else if (p[1] == '%')
+		{
+		    /* translate \% into % */
+		    reg_pat[i++] = '%';
+		    ++p;
+		    break;
+		}
 #ifdef BACKSLASH_IN_FILENAME
 		if (!no_bslash)
 		{

Raspunde prin e-mail lui