diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-07-08 23:29:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-08 23:29:24 +0800 |
commit | fbeef0d4ef1aadc4e50b9f33946cf4dca8ca6b62 (patch) | |
tree | b23befeae7113e5a559227454a5155e579bd5f69 /src/nvim/path.c | |
parent | b9a0e762f1d79d17631b7d17cf25b6e25006d8c2 (diff) | |
download | rneovim-fbeef0d4ef1aadc4e50b9f33946cf4dca8ca6b62.tar.gz rneovim-fbeef0d4ef1aadc4e50b9f33946cf4dca8ca6b62.tar.bz2 rneovim-fbeef0d4ef1aadc4e50b9f33946cf4dca8ca6b62.zip |
fix(completion): don't add backslashes to runtime pattern (#24296)
Problem: Bashslashes added as regexp in runtime completion may be
treated as path separator with some 'isfname' value.
Solution: Make curly braces work for runtime completion and use it.
Diffstat (limited to 'src/nvim/path.c')
-rw-r--r-- | src/nvim/path.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/nvim/path.c b/src/nvim/path.c index b9ae756027..828b690699 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -1163,7 +1163,7 @@ static bool has_env_var(char *p) // Return true if "p" contains a special wildcard character, one that Vim // cannot expand, requires using a shell. -static bool has_special_wildchar(char *p) +static bool has_special_wildchar(char *p, int flags) { for (; *p; MB_PTR_ADV(p)) { // Disallow line break characters. @@ -1174,6 +1174,10 @@ static bool has_special_wildchar(char *p) if (*p == '\\' && p[1] != NUL && p[1] != '\r' && p[1] != '\n') { p++; } else if (vim_strchr(SPECIAL_WILDCHAR, (uint8_t)(*p)) != NULL) { + // Need a shell for curly braces only when including non-existing files. + if (*p == '{' && !(flags & EW_NOTFOUND)) { + continue; + } // A { must be followed by a matching }. if (*p == '{' && vim_strchr(p, '}') == NULL) { continue; @@ -1233,7 +1237,7 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i // avoids starting the shell for each argument separately. // For `=expr` do use the internal function. for (int i = 0; i < num_pat; i++) { - if (has_special_wildchar(pat[i]) + if (has_special_wildchar(pat[i], flags) && !(vim_backtick(pat[i]) && pat[i][1] == '=')) { return os_expand_wildcards(num_pat, pat, num_file, file, flags); } |