mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.0335: no completion for :disassemble
Problem: No completion for :disassemble. Solution: Make completion work. Also complete script-local functions if the name starts with "s:".
This commit is contained in:
@@ -149,6 +149,12 @@ with `substitute(` this will use the function, prepend a colon to use the
|
|||||||
command instead: >
|
command instead: >
|
||||||
:substitute(pattern (replacement (
|
:substitute(pattern (replacement (
|
||||||
|
|
||||||
|
Note that while variables need to be defined before they can be used,
|
||||||
|
functions can be called before being defined. This is required to be able
|
||||||
|
have cyclic dependencies between functions. It is slightly less efficient,
|
||||||
|
since the function has to be looked up by name. And a typo in the function
|
||||||
|
name will only be found when the call is executed.
|
||||||
|
|
||||||
|
|
||||||
No curly braces expansion ~
|
No curly braces expansion ~
|
||||||
|
|
||||||
@@ -275,6 +281,8 @@ script, then script-local variables must be accessed with the "s:" prefix.
|
|||||||
*:disa* *:disassemble*
|
*:disa* *:disassemble*
|
||||||
:disa[ssemble] {func} Show the instructions generated for {func}.
|
:disa[ssemble] {func} Show the instructions generated for {func}.
|
||||||
This is for debugging and testing.
|
This is for debugging and testing.
|
||||||
|
Note that for command line completion of {func} you
|
||||||
|
can prepend "s:" to find script-local functions.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
|
@@ -1550,6 +1550,7 @@ set_one_cmd_context(
|
|||||||
|
|
||||||
case CMD_function:
|
case CMD_function:
|
||||||
case CMD_delfunction:
|
case CMD_delfunction:
|
||||||
|
case CMD_disassemble:
|
||||||
xp->xp_context = EXPAND_USER_FUNC;
|
xp->xp_context = EXPAND_USER_FUNC;
|
||||||
xp->xp_pattern = arg;
|
xp->xp_pattern = arg;
|
||||||
break;
|
break;
|
||||||
@@ -1978,6 +1979,7 @@ ExpandFromContext(
|
|||||||
regmatch_T regmatch;
|
regmatch_T regmatch;
|
||||||
int ret;
|
int ret;
|
||||||
int flags;
|
int flags;
|
||||||
|
char_u *tofree = NULL;
|
||||||
|
|
||||||
flags = EW_DIR; // include directories
|
flags = EW_DIR; // include directories
|
||||||
if (options & WILD_LIST_NOTFOUND)
|
if (options & WILD_LIST_NOTFOUND)
|
||||||
@@ -2115,6 +2117,17 @@ ExpandFromContext(
|
|||||||
if (xp->xp_context == EXPAND_PACKADD)
|
if (xp->xp_context == EXPAND_PACKADD)
|
||||||
return ExpandPackAddDir(pat, num_file, file);
|
return ExpandPackAddDir(pat, num_file, file);
|
||||||
|
|
||||||
|
// When expanding a function name starting with s:, match the <SNR>nr_
|
||||||
|
// prefix.
|
||||||
|
if (xp->xp_context == EXPAND_USER_FUNC && STRNCMP(pat, "^s:", 3) == 0)
|
||||||
|
{
|
||||||
|
int len = (int)STRLEN(pat) + 20;
|
||||||
|
|
||||||
|
tofree = alloc(len);
|
||||||
|
snprintf((char *)tofree, len, "^<SNR>\\d\\+_%s", pat + 3);
|
||||||
|
pat = tofree;
|
||||||
|
}
|
||||||
|
|
||||||
regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0);
|
regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0);
|
||||||
if (regmatch.regprog == NULL)
|
if (regmatch.regprog == NULL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -2204,6 +2217,7 @@ ExpandFromContext(
|
|||||||
}
|
}
|
||||||
|
|
||||||
vim_regfree(regmatch.regprog);
|
vim_regfree(regmatch.regprog);
|
||||||
|
vim_free(tofree);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -559,6 +559,17 @@ func Test_cmdline_complete_user_cmd()
|
|||||||
delcommand Foo
|
delcommand Foo
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func s:ScriptLocalFunction()
|
||||||
|
echo 'yes'
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_cmdline_complete_user_func()
|
||||||
|
call feedkeys(":func Test_cmdline_complete_user\<Tab>\<Home>\"\<cr>", 'tx')
|
||||||
|
call assert_match('"func Test_cmdline_complete_user', @:)
|
||||||
|
call feedkeys(":func s:ScriptL\<Tab>\<Home>\"\<cr>", 'tx')
|
||||||
|
call assert_match('"func <SNR>\d\+_ScriptLocalFunction', @:)
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_cmdline_complete_user_names()
|
func Test_cmdline_complete_user_names()
|
||||||
if has('unix') && executable('whoami')
|
if has('unix') && executable('whoami')
|
||||||
let whoami = systemlist('whoami')[0]
|
let whoami = systemlist('whoami')[0]
|
||||||
|
@@ -738,6 +738,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
335,
|
||||||
/**/
|
/**/
|
||||||
334,
|
334,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user