summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-02-29 22:06:30 +0100
committerBram Moolenaar <Bram@vim.org>2020-02-29 22:06:30 +0100
commitcc390ff5b2c8725c55b961b24322c470659ede9f (patch)
treeb79b29bf770a6de9d484accad77cee9ac41bcec6 /src
parentdd58923c6bcb026de7134d9874e69e0a2b01682d (diff)
patch 8.2.0335: no completion for :disassemblev8.2.0335
Problem: No completion for :disassemble. Solution: Make completion work. Also complete script-local functions if the name starts with "s:".
Diffstat (limited to 'src')
-rw-r--r--src/cmdexpand.c14
-rw-r--r--src/testdir/test_cmdline.vim11
-rw-r--r--src/version.c2
3 files changed, 27 insertions, 0 deletions
diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index b5da922fd1..ece5a468b1 100644
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -1550,6 +1550,7 @@ set_one_cmd_context(
case CMD_function:
case CMD_delfunction:
+ case CMD_disassemble:
xp->xp_context = EXPAND_USER_FUNC;
xp->xp_pattern = arg;
break;
@@ -1978,6 +1979,7 @@ ExpandFromContext(
regmatch_T regmatch;
int ret;
int flags;
+ char_u *tofree = NULL;
flags = EW_DIR; // include directories
if (options & WILD_LIST_NOTFOUND)
@@ -2115,6 +2117,17 @@ ExpandFromContext(
if (xp->xp_context == EXPAND_PACKADD)
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);
if (regmatch.regprog == NULL)
return FAIL;
@@ -2204,6 +2217,7 @@ ExpandFromContext(
}
vim_regfree(regmatch.regprog);
+ vim_free(tofree);
return ret;
}
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 1baed7961f..8c580262ac 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -559,6 +559,17 @@ func Test_cmdline_complete_user_cmd()
delcommand Foo
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()
if has('unix') && executable('whoami')
let whoami = systemlist('whoami')[0]
diff --git a/src/version.c b/src/version.c
index 4dc9642a5c..23c45082c7 100644
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 335,
+/**/
334,
/**/
333,