Mercurial > vim
comparison src/cmdexpand.c @ 27899:5426a1d3f12d v8.2.4475
patch 8.2.4475: fuzzy cmdline completion does not work for lower case
Commit: https://github.com/vim/vim/commit/4df5b33f206210fec2a0297aea27e7db8b5173c0
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sat Feb 26 11:04:42 2022 +0000
patch 8.2.4475: fuzzy cmdline completion does not work for lower case
Problem: Fuzzy cmdline completion does not work for lower case.
Solution: Also use fuzzy completion for lower case input. (Yegappan
Lakshmanan, closes #9849)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 26 Feb 2022 12:15:02 +0100 |
parents | 76e2115dddb8 |
children | 7422add1afd1 |
comparison
equal
deleted
inserted
replaced
27898:c53b4662bdba | 27899:5426a1d3f12d |
---|---|
1210 static char_u * | 1210 static char_u * |
1211 set_cmd_index(char_u *cmd, exarg_T *eap, expand_T *xp, int *complp) | 1211 set_cmd_index(char_u *cmd, exarg_T *eap, expand_T *xp, int *complp) |
1212 { | 1212 { |
1213 char_u *p = NULL; | 1213 char_u *p = NULL; |
1214 int len = 0; | 1214 int len = 0; |
1215 int fuzzy = cmdline_fuzzy_complete(cmd); | |
1215 | 1216 |
1216 // Isolate the command and search for it in the command table. | 1217 // Isolate the command and search for it in the command table. |
1217 // Exceptions: | 1218 // Exceptions: |
1218 // - the 'k' command can directly be followed by any character, but | 1219 // - the 'k' command can directly be followed by any character, but |
1219 // do accept "keepmarks", "keepalt" and "keepjumps". | 1220 // do accept "keepmarks", "keepalt" and "keepjumps". |
1251 return NULL; | 1252 return NULL; |
1252 } | 1253 } |
1253 | 1254 |
1254 eap->cmdidx = excmd_get_cmdidx(cmd, len); | 1255 eap->cmdidx = excmd_get_cmdidx(cmd, len); |
1255 | 1256 |
1256 if (cmd[0] >= 'A' && cmd[0] <= 'Z') | 1257 // User defined commands support alphanumeric characters. |
1258 // Also when doing fuzzy expansion, support alphanumeric characters. | |
1259 if ((cmd[0] >= 'A' && cmd[0] <= 'Z') || (fuzzy && *p != NUL)) | |
1257 while (ASCII_ISALNUM(*p) || *p == '*') // Allow * wild card | 1260 while (ASCII_ISALNUM(*p) || *p == '*') // Allow * wild card |
1258 ++p; | 1261 ++p; |
1259 } | 1262 } |
1260 | 1263 |
1261 // If the cursor is touching the command, and it ends in an alphanumeric | 1264 // If the cursor is touching the command, and it ends in an alphanumeric |
2491 { | 2494 { |
2492 regmatch_T regmatch; | 2495 regmatch_T regmatch; |
2493 int ret; | 2496 int ret; |
2494 int flags; | 2497 int flags; |
2495 char_u *tofree = NULL; | 2498 char_u *tofree = NULL; |
2499 int fuzzy = cmdline_fuzzy_complete(pat); | |
2496 | 2500 |
2497 flags = map_wildopts_to_ewflags(options); | 2501 flags = map_wildopts_to_ewflags(options); |
2498 | 2502 |
2499 if (xp->xp_context == EXPAND_FILES | 2503 if (xp->xp_context == EXPAND_FILES |
2500 || xp->xp_context == EXPAND_DIRECTORIES | 2504 || xp->xp_context == EXPAND_DIRECTORIES |
2575 return FAIL; | 2579 return FAIL; |
2576 vim_snprintf((char *)tofree, len, "^<SNR>\\d\\+_%s", pat + 3); | 2580 vim_snprintf((char *)tofree, len, "^<SNR>\\d\\+_%s", pat + 3); |
2577 pat = tofree; | 2581 pat = tofree; |
2578 } | 2582 } |
2579 | 2583 |
2580 regmatch.regprog = vim_regcomp(pat, magic_isset() ? RE_MAGIC : 0); | 2584 if (!fuzzy) |
2581 if (regmatch.regprog == NULL) | 2585 { |
2582 return FAIL; | 2586 regmatch.regprog = vim_regcomp(pat, magic_isset() ? RE_MAGIC : 0); |
2583 | 2587 if (regmatch.regprog == NULL) |
2584 // set ignore-case according to p_ic, p_scs and pat | 2588 return FAIL; |
2585 regmatch.rm_ic = ignorecase(pat); | 2589 |
2590 // set ignore-case according to p_ic, p_scs and pat | |
2591 regmatch.rm_ic = ignorecase(pat); | |
2592 } | |
2586 | 2593 |
2587 if (xp->xp_context == EXPAND_SETTINGS | 2594 if (xp->xp_context == EXPAND_SETTINGS |
2588 || xp->xp_context == EXPAND_BOOL_SETTINGS) | 2595 || xp->xp_context == EXPAND_BOOL_SETTINGS) |
2589 ret = ExpandSettings(xp, ®match, pat, numMatches, matches); | 2596 ret = ExpandSettings(xp, ®match, pat, numMatches, matches); |
2590 else if (xp->xp_context == EXPAND_MAPPINGS) | 2597 else if (xp->xp_context == EXPAND_MAPPINGS) |
2594 ret = ExpandUserDefined(xp, ®match, matches, numMatches); | 2601 ret = ExpandUserDefined(xp, ®match, matches, numMatches); |
2595 # endif | 2602 # endif |
2596 else | 2603 else |
2597 ret = ExpandOther(pat, xp, ®match, matches, numMatches); | 2604 ret = ExpandOther(pat, xp, ®match, matches, numMatches); |
2598 | 2605 |
2599 vim_regfree(regmatch.regprog); | 2606 if (!fuzzy) |
2607 vim_regfree(regmatch.regprog); | |
2600 vim_free(tofree); | 2608 vim_free(tofree); |
2601 | 2609 |
2602 return ret; | 2610 return ret; |
2603 } | 2611 } |
2604 | 2612 |