aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/path.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-09-03 09:39:13 +0800
committerGitHub <noreply@github.com>2022-09-03 09:39:13 +0800
commit042d5df9567bc37fb4a46bcf43f0f46b16eadf6d (patch)
treeee597105bada2b66d4d51b6086c70b5e8c39e48a /src/nvim/path.c
parent1ffd527c837fb2465c9659273bbe5447a1352db2 (diff)
parentc62e5b50795d38db68f198a3d1230c047fc0ccfa (diff)
downloadrneovim-042d5df9567bc37fb4a46bcf43f0f46b16eadf6d.tar.gz
rneovim-042d5df9567bc37fb4a46bcf43f0f46b16eadf6d.tar.bz2
rneovim-042d5df9567bc37fb4a46bcf43f0f46b16eadf6d.zip
Merge pull request #20063 from zeertzjq/vim-9.0.0360
vim-patch:8.2.1505,9.0.{0360,0362}
Diffstat (limited to 'src/nvim/path.c')
-rw-r--r--src/nvim/path.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 607f1fc09a..1e5fa49ad6 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -2106,13 +2106,16 @@ int expand_wildcards_eval(char_u **pat, int *num_file, char ***file, int flags)
char *exp_pat = (char *)(*pat);
char *ignored_msg;
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++;
eval_pat = eval_vars((char_u *)exp_pat, (char_u *)exp_pat, &usedlen, NULL, &ignored_msg, NULL,
true);
emsg_off--;
if (eval_pat != NULL) {
+ star_follows = strcmp(exp_pat + usedlen, "*") == 0;
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 (*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(eval_pat);
}