vim-patch:9.0.1242: code for :runtime completion is not consistent

Problem:    Code for :runtime completion is not consistent.
Solution:   Make code for cmdline expansion more consistent. (closes vim/vim#11875)

b0d45ec67f
This commit is contained in:
zeertzjq
2023-01-26 10:53:32 +08:00
parent f03f6263bb
commit ebc80dcded
3 changed files with 14 additions and 14 deletions

View File

@@ -1212,11 +1212,11 @@ char *addstar(char *fname, size_t len, int context)
if (context == EXPAND_HELP if (context == EXPAND_HELP
|| context == EXPAND_CHECKHEALTH || context == EXPAND_CHECKHEALTH
|| context == EXPAND_COLORS || context == EXPAND_COLORS
|| context == EXPAND_RUNTIME
|| context == EXPAND_COMPILER || context == EXPAND_COMPILER
|| context == EXPAND_OWNSYNTAX || context == EXPAND_OWNSYNTAX
|| context == EXPAND_FILETYPE || context == EXPAND_FILETYPE
|| context == EXPAND_PACKADD || context == EXPAND_PACKADD
|| context == EXPAND_RUNTIME
|| ((context == EXPAND_TAGS_LISTFILES || context == EXPAND_TAGS) || ((context == EXPAND_TAGS_LISTFILES || context == EXPAND_TAGS)
&& fname[0] == '/')) { && fname[0] == '/')) {
retval = xstrnsave(fname, len); retval = xstrnsave(fname, len);
@@ -2074,10 +2074,6 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, expa
xp->xp_pattern = (char *)arg; xp->xp_pattern = (char *)arg;
break; break;
case CMD_runtime:
set_context_in_runtime_cmd(xp, arg);
break;
case CMD_compiler: case CMD_compiler:
xp->xp_context = EXPAND_COMPILER; xp->xp_context = EXPAND_COMPILER;
xp->xp_pattern = (char *)arg; xp->xp_pattern = (char *)arg;
@@ -2098,6 +2094,10 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, expa
xp->xp_pattern = (char *)arg; xp->xp_pattern = (char *)arg;
break; break;
case CMD_runtime:
set_context_in_runtime_cmd(xp, arg);
break;
#ifdef HAVE_WORKING_LIBINTL #ifdef HAVE_WORKING_LIBINTL
case CMD_language: case CMD_language:
return set_context_in_lang_cmd(xp, arg); return set_context_in_lang_cmd(xp, arg);

View File

@@ -4824,12 +4824,12 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, char *fuzzystr, int *numM
return OK; return OK;
} }
void ExpandOldSetting(int *num_file, char ***file) void ExpandOldSetting(int *numMatches, char ***matches)
{ {
char *var = NULL; char *var = NULL;
*num_file = 0; *numMatches = 0;
*file = xmalloc(sizeof(char_u *)); *matches = xmalloc(sizeof(char *));
// For a terminal key code expand_option_idx is < 0. // For a terminal key code expand_option_idx is < 0.
if (expand_option_idx < 0) { if (expand_option_idx < 0) {
@@ -4862,8 +4862,8 @@ void ExpandOldSetting(int *num_file, char ***file)
} }
#endif #endif
*file[0] = buf; *matches[0] = buf;
*num_file = 1; *numMatches = 1;
} }
/// Get the value for the numeric or string option///opp in a nice format into /// Get the value for the numeric or string option///opp in a nice format into

View File

@@ -26,7 +26,7 @@ func Test_packadd()
let rtp_entries = split(rtp, ',') let rtp_entries = split(rtp, ',')
for entry in rtp_entries for entry in rtp_entries
if entry =~? '\<after\>' if entry =~? '\<after\>'
let first_after_entry = entry let first_after_entry = entry
break break
endif endif
@@ -186,7 +186,7 @@ func Test_packadd_symlink_dir2()
exec "silent !rmdir" top2_dir exec "silent !rmdir" top2_dir
endfunc endfunc
" Check command-line completion for 'packadd' " Check command-line completion for :packadd
func Test_packadd_completion() func Test_packadd_completion()
let optdir1 = &packpath . '/pack/mine/opt' let optdir1 = &packpath . '/pack/mine/opt'
let optdir2 = &packpath . '/pack/candidate/opt' let optdir2 = &packpath . '/pack/candidate/opt'
@@ -262,9 +262,9 @@ func Test_helptags()
helptags ALL helptags ALL
let tags1 = readfile(docdir1 . '/tags') let tags1 = readfile(docdir1 . '/tags')
call assert_match('look-here', tags1[0]) call assert_match('look-here', tags1[0])
let tags2 = readfile(docdir2 . '/tags') let tags2 = readfile(docdir2 . '/tags')
call assert_match('look-away', tags2[0]) call assert_match('look-away', tags2[0])
call assert_fails('helptags abcxyz', 'E150:') call assert_fails('helptags abcxyz', 'E150:')