[patch] fixed E71 & inconsistent completion behavior with % in file names

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[patch] fixed E71 & inconsistent completion behavior with % in file names

Dominique Pellé
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

fixed-file_compl_%-fileio.c-7.3a.patch (528 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [patch] fixed E71 & inconsistent completion behavior with % in file names

Bram Moolenaar

Dominique Pelle wrote:

> 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.

Thanks.  I think it's the right place to change this.  I found a few
more characters with problems, especially a file name "foo*bar".
I'll make a fix, please test the version I just pushed to the vim73
branch.

--
Amazing but true: If all the salmon caught in Canada in one year were laid
end to end across the Sahara Desert, the smell would be absolutely awful.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
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