mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 21:25:04 -07:00
ex_docmd.c: Allow unescaped spaces in :edit filename (#6119)
This makes :edit consistent on all platforms. Also affects :argedit, et al. Wild (tab) completion doesn't work, though. Closes #6010
This commit is contained in:
parent
64c375c589
commit
0e44916fff
@ -3940,8 +3940,6 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
|
|||||||
* Don't do this for:
|
* Don't do this for:
|
||||||
* - replacement that already has been escaped: "##"
|
* - replacement that already has been escaped: "##"
|
||||||
* - shell commands (may have to use quotes instead).
|
* - shell commands (may have to use quotes instead).
|
||||||
* - non-unix systems when there is a single argument (spaces don't
|
|
||||||
* separate arguments then).
|
|
||||||
*/
|
*/
|
||||||
if (!eap->usefilter
|
if (!eap->usefilter
|
||||||
&& !escaped
|
&& !escaped
|
||||||
@ -3952,9 +3950,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
|
|||||||
&& eap->cmdidx != CMD_lgrep
|
&& eap->cmdidx != CMD_lgrep
|
||||||
&& eap->cmdidx != CMD_grepadd
|
&& eap->cmdidx != CMD_grepadd
|
||||||
&& eap->cmdidx != CMD_lgrepadd
|
&& eap->cmdidx != CMD_lgrepadd
|
||||||
#ifndef UNIX
|
|
||||||
&& !(eap->argt & NOSPC)
|
&& !(eap->argt & NOSPC)
|
||||||
#endif
|
|
||||||
) {
|
) {
|
||||||
char_u *l;
|
char_u *l;
|
||||||
#ifdef BACKSLASH_IN_FILENAME
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
@ -4016,28 +4012,6 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace any other wildcards, remove backslashes.
|
|
||||||
#ifdef UNIX
|
|
||||||
/*
|
|
||||||
* Only for Unix we check for more than one file name.
|
|
||||||
* For other systems spaces are considered to be part
|
|
||||||
* of the file name.
|
|
||||||
* Only check here if there is no wildcard, otherwise
|
|
||||||
* ExpandOne() will check for errors. This allows
|
|
||||||
* ":e `ls ve*.c`" on Unix.
|
|
||||||
*/
|
|
||||||
if (!has_wildcards)
|
|
||||||
for (p = eap->arg; *p; ++p) {
|
|
||||||
/* skip escaped characters */
|
|
||||||
if (p[1] && (*p == '\\' || *p == Ctrl_V))
|
|
||||||
++p;
|
|
||||||
else if (ascii_iswhite(*p)) {
|
|
||||||
*errormsgp = (char_u *)_("E172: Only one file name allowed");
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Halve the number of backslashes (this is Vi compatible).
|
* Halve the number of backslashes (this is Vi compatible).
|
||||||
* For Unix, when wildcards are expanded, this is
|
* For Unix, when wildcards are expanded, this is
|
||||||
|
@ -222,7 +222,6 @@ describe('argument list commands', function()
|
|||||||
execute('argedit a')
|
execute('argedit a')
|
||||||
eq({'a', 'b'}, eval('argv()'))
|
eq({'a', 'b'}, eval('argv()'))
|
||||||
eq('a', eval('expand("%:t")'))
|
eq('a', eval('expand("%:t")'))
|
||||||
assert_fails('argedit a b', 'E172:')
|
|
||||||
execute('argedit c')
|
execute('argedit c')
|
||||||
eq({'a', 'c', 'b'}, eval('argv()'))
|
eq({'a', 'c', 'b'}, eval('argv()'))
|
||||||
execute('0argedit x')
|
execute('0argedit x')
|
||||||
@ -232,6 +231,9 @@ describe('argument list commands', function()
|
|||||||
execute('argedit! y')
|
execute('argedit! y')
|
||||||
eq({'x', 'y', 'a', 'c', 'b'}, eval('argv()'))
|
eq({'x', 'y', 'a', 'c', 'b'}, eval('argv()'))
|
||||||
execute('%argd')
|
execute('%argd')
|
||||||
|
-- Nvim allows unescaped spaces in filename on all platforms. #6010
|
||||||
|
execute('argedit a b')
|
||||||
|
eq({'a b'}, eval('argv()'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('test for :argdelete command', function()
|
it('test for :argdelete command', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user