diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_getln.c | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 35454ba316..a7efe5f533 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3590,40 +3590,33 @@ nextwild ( xp->xp_pattern_len = ccline.cmdpos - i; if (type == WILD_NEXT || type == WILD_PREV) { - /* - * Get next/previous match for a previous expanded pattern. - */ + // Get next/previous match for a previous expanded pattern. p2 = ExpandOne(xp, NULL, NULL, 0, type); } else { - /* - * Translate string into pattern and expand it. - */ - if ((p1 = addstar(xp->xp_pattern, xp->xp_pattern_len, - xp->xp_context)) == NULL) - p2 = NULL; - else { - int use_options = options | - WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT; - if (escape) - use_options |= WILD_ESCAPE; - - if (p_wic) - use_options += WILD_ICASE; - p2 = ExpandOne(xp, p1, - vim_strnsave(&ccline.cmdbuff[i], xp->xp_pattern_len), - use_options, type); - xfree(p1); - /* longest match: make sure it is not shorter, happens with :help */ - if (p2 != NULL && type == WILD_LONGEST) { - for (j = 0; j < xp->xp_pattern_len; ++j) - if (ccline.cmdbuff[i + j] == '*' - || ccline.cmdbuff[i + j] == '?') - break; - if ((int)STRLEN(p2) < j) { - xfree(p2); - p2 = NULL; + // Translate string into pattern and expand it. + p1 = addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context); + const int use_options = ( + options + | WILD_HOME_REPLACE + | WILD_ADD_SLASH + | WILD_SILENT + | (escape ? WILD_ESCAPE : 0) + | (p_wic ? WILD_ICASE : 0)); + p2 = ExpandOne(xp, p1, vim_strnsave(&ccline.cmdbuff[i], xp->xp_pattern_len), + use_options, type); + xfree(p1); + // Longest match: make sure it is not shorter, happens with :help. + if (p2 != NULL && type == WILD_LONGEST) { + for (j = 0; j < xp->xp_pattern_len; j++) { + if (ccline.cmdbuff[i + j] == '*' + || ccline.cmdbuff[i + j] == '?') { + break; } } + if ((int)STRLEN(p2) < j) { + xfree(p2); + p2 = NULL; + } } } |