mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.0.0362: expanding ":e %" does not work for remote files
Problem: Expanding ":e %" does not work for remote files.
Solution: If the "%" or "#" file does not exist add the expansion anyway.
f5724376ab
This commit is contained in:
parent
7243b1cbde
commit
c62e5b5079
@ -2106,13 +2106,16 @@ int expand_wildcards_eval(char_u **pat, int *num_file, char ***file, int flags)
|
|||||||
char *exp_pat = (char *)(*pat);
|
char *exp_pat = (char *)(*pat);
|
||||||
char *ignored_msg;
|
char *ignored_msg;
|
||||||
size_t usedlen;
|
size_t usedlen;
|
||||||
|
const bool is_cur_alt_file = *exp_pat == '%' || *exp_pat == '#';
|
||||||
|
bool star_follows = false;
|
||||||
|
|
||||||
if (*exp_pat == '%' || *exp_pat == '#' || *exp_pat == '<') {
|
if (is_cur_alt_file || *exp_pat == '<') {
|
||||||
emsg_off++;
|
emsg_off++;
|
||||||
eval_pat = eval_vars((char_u *)exp_pat, (char_u *)exp_pat, &usedlen, NULL, &ignored_msg, NULL,
|
eval_pat = eval_vars((char_u *)exp_pat, (char_u *)exp_pat, &usedlen, NULL, &ignored_msg, NULL,
|
||||||
true);
|
true);
|
||||||
emsg_off--;
|
emsg_off--;
|
||||||
if (eval_pat != NULL) {
|
if (eval_pat != NULL) {
|
||||||
|
star_follows = strcmp(exp_pat + usedlen, "*") == 0;
|
||||||
exp_pat = concat_str((char *)eval_pat, exp_pat + usedlen);
|
exp_pat = concat_str((char *)eval_pat, exp_pat + usedlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2122,6 +2125,16 @@ int expand_wildcards_eval(char_u **pat, int *num_file, char ***file, int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (eval_pat != NULL) {
|
if (eval_pat != NULL) {
|
||||||
|
if (*num_file == 0 && is_cur_alt_file && star_follows) {
|
||||||
|
// Expanding "%" or "#" and the file does not exist: Add the
|
||||||
|
// pattern anyway (without the star) so that this works for remote
|
||||||
|
// files and non-file buffer names.
|
||||||
|
*file = xmalloc(sizeof(char *));
|
||||||
|
**file = (char *)eval_pat;
|
||||||
|
eval_pat = NULL;
|
||||||
|
*num_file = 1;
|
||||||
|
ret = OK;
|
||||||
|
}
|
||||||
xfree(exp_pat);
|
xfree(exp_pat);
|
||||||
xfree(eval_pat);
|
xfree(eval_pat);
|
||||||
}
|
}
|
||||||
|
@ -1055,6 +1055,18 @@ func Test_cmdline_write_alternatefile()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_cmdline_expand_cur_alt_file()
|
||||||
|
enew
|
||||||
|
file http://some.com/file.txt
|
||||||
|
call feedkeys(":e %\<Tab>\<C-B>\"\<CR>", 'xt')
|
||||||
|
call assert_equal('"e http://some.com/file.txt', @:)
|
||||||
|
edit another
|
||||||
|
call feedkeys(":e #\<Tab>\<C-B>\"\<CR>", 'xt')
|
||||||
|
call assert_equal('"e http://some.com/file.txt', @:)
|
||||||
|
bwipe
|
||||||
|
bwipe http://some.com/file.txt
|
||||||
|
endfunc
|
||||||
|
|
||||||
" using a leading backslash here
|
" using a leading backslash here
|
||||||
set cpo+=C
|
set cpo+=C
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user