diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/cmdexpand.c | 29 | ||||
-rw-r--r-- | src/nvim/cmdexpand_defs.h | 7 | ||||
-rw-r--r-- | src/nvim/option.c | 11 | ||||
-rw-r--r-- | src/nvim/options.lua | 4 |
4 files changed, 38 insertions, 13 deletions
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index c2469b6574..38be6573c8 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -156,8 +156,9 @@ static void wildescape(expand_T *xp, const char *str, int numfiles, char **files // and wildmatch characters, except '~'. for (int i = 0; i < numfiles; i++) { // for ":set path=" we need to escape spaces twice - if (xp->xp_backslash == XP_BS_THREE) { - p = vim_strsave_escaped(files[i], " "); + if (xp->xp_backslash & XP_BS_THREE) { + char *pat = (xp->xp_backslash & XP_BS_COMMA) ? " ," : " "; + p = vim_strsave_escaped(files[i], pat); xfree(files[i]); files[i] = p; #if defined(BACKSLASH_IN_FILENAME) @@ -165,6 +166,14 @@ static void wildescape(expand_T *xp, const char *str, int numfiles, char **files xfree(files[i]); files[i] = p; #endif + } else if (xp->xp_backslash & XP_BS_COMMA) { + if (vim_strchr(files[i], ',') != NULL) { + p = vim_strsave_escaped(files[i], ","); + if (p != NULL) { + xfree(files[i]); + files[i] = p; + } + } } #ifdef BACKSLASH_IN_FILENAME p = vim_strsave_fnameescape(files[i], vse_what); @@ -2440,15 +2449,23 @@ static int expand_files_and_dirs(expand_T *xp, char *pat, char ***matches, int * pat = xstrdup(pat); for (int i = 0; pat[i]; i++) { if (pat[i] == '\\') { - if (xp->xp_backslash == XP_BS_THREE + if (xp->xp_backslash & XP_BS_THREE && pat[i + 1] == '\\' && pat[i + 2] == '\\' && pat[i + 3] == ' ') { STRMOVE(pat + i, pat + i + 3); - } - if (xp->xp_backslash == XP_BS_ONE - && pat[i + 1] == ' ') { + } else if (xp->xp_backslash & XP_BS_ONE + && pat[i + 1] == ' ') { STRMOVE(pat + i, pat + i + 1); + } else if ((xp->xp_backslash & XP_BS_COMMA) + && pat[i + 1] == '\\' + && pat[i + 2] == ',') { + STRMOVE(pat + i, pat + i + 2); +#ifdef BACKSLASH_IN_FILENAME + } else if ((xp->xp_backslash & XP_BS_COMMA) + && pat[i + 1] == ',') { + STRMOVE(pat + i, pat + i + 1); +#endif } } } diff --git a/src/nvim/cmdexpand_defs.h b/src/nvim/cmdexpand_defs.h index a302a32852..7c422aca18 100644 --- a/src/nvim/cmdexpand_defs.h +++ b/src/nvim/cmdexpand_defs.h @@ -40,9 +40,10 @@ typedef struct expand { /// values for xp_backslash enum { - XP_BS_NONE = 0, ///< nothing special for backslashes - XP_BS_ONE = 1, ///< uses one backslash before a space - XP_BS_THREE = 2, ///< uses three backslashes before a space + XP_BS_NONE = 0, ///< nothing special for backslashes + XP_BS_ONE = 0x1, ///< uses one backslash before a space + XP_BS_THREE = 0x2, ///< uses three backslashes before a space + XP_BS_COMMA = 0x4, ///< commas need to be escaped with a backslash }; /// values for xp_context when doing command line completion diff --git a/src/nvim/option.c b/src/nvim/option.c index c0353e52be..0700d0e87e 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -5496,6 +5496,9 @@ void set_context_in_set_cmd(expand_T *xp, char *arg, int opt_flags) xp->xp_backslash = XP_BS_ONE; } } + if (flags & P_COMMA) { + xp->xp_backslash |= XP_BS_COMMA; + } } // For an option that is a list of file names, or comma/colon-separated @@ -5511,8 +5514,12 @@ void set_context_in_set_cmd(expand_T *xp, char *arg, int opt_flags) while (s > xp->xp_pattern && *(s - 1) == '\\') { s--; } - if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) - || (*p == ',' && (flags & P_COMMA) && ((p - s) % 1) == 0) + if ((*p == ' ' && ((xp->xp_backslash & XP_BS_THREE) && (p - s) < 3)) +#if defined(BACKSLASH_IN_FILENAME) + || (*p == ',' && (flags & P_COMMA) && (p - s) < 1) +#else + || (*p == ',' && (flags & P_COMMA) && (p - s) < 2) +#endif || (*p == ':' && (flags & P_COLON))) { xp->xp_pattern = p + 1; break; diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 68d88ea0aa..d5f41c5a89 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -8679,8 +8679,8 @@ return { deny_duplicates = true, desc = [=[ Filenames for the tag command, separated by spaces or commas. To - include a space or comma in a file name, precede it with a backslash - (see |option-backslash| about including spaces and backslashes). + include a space or comma in a file name, precede it with backslashes + (see |option-backslash| about including spaces/commas and backslashes). When a file name starts with "./", the '.' is replaced with the path of the current file. But only when the 'd' flag is not included in 'cpoptions'. Environment variables are expanded |:set_env|. Also see |