Patch 8.2.0335
Problem: No completion for :disassemble.
Solution: Make completion work. Also complete script-local functions if the
name starts with "s:".
Files: src/cmdexpand.c, src/testdir/test_cmdline.vim,
runtime/doc/vim9.txt
*** ../vim-8.2.0334/src/cmdexpand.c 2020-01-07 21:05:45.627365256 +0100
--- src/cmdexpand.c 2020-02-29 21:52:38.194297156 +0100
***************
*** 1550,1555 ****
--- 1550,1556 ----
case CMD_function:
case CMD_delfunction:
+ case CMD_disassemble:
xp->xp_context = EXPAND_USER_FUNC;
xp->xp_pattern = arg;
break;
***************
*** 1978,1983 ****
--- 1979,1985 ----
regmatch_T regmatch;
int ret;
int flags;
+ char_u *tofree = NULL;
flags = EW_DIR; // include directories
if (options & WILD_LIST_NOTFOUND)
***************
*** 2115,2120 ****
--- 2117,2133 ----
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,2209 ****
--- 2217,2223 ----
}
vim_regfree(regmatch.regprog);
+ vim_free(tofree);
return ret;
}
*** ../vim-8.2.0334/src/testdir/test_cmdline.vim 2020-02-29 14:23:54.753706663 +0100
--- src/testdir/test_cmdline.vim 2020-02-29 22:05:29.043886522 +0100
***************
*** 559,564 ****
--- 559,575 ----
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]
*** ../vim-8.2.0334/runtime/doc/vim9.txt 2020-02-22 18:36:18.608483742 +0100
--- runtime/doc/vim9.txt 2020-02-29 21:57:44.713339679 +0100
***************
*** 149,154 ****
--- 149,160 ----
command instead: >
: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 ~
***************
*** 275,280 ****
--- 281,288 ----
*:disa* *:disassemble*
:disa[ssemble] {func} Show the instructions generated for {func}.
This is for debugging and testing.
+ Note that for command line completion of {func} you
+ can prepend "s:" to find script-local functions.
==============================================================================
*** ../vim-8.2.0334/src/version.c 2020-02-29 17:38:08.866485874 +0100
--- src/version.c 2020-02-29 21:40:10.060631812 +0100
***************
*** 740,741 ****
--- 740,743 ----
{ /* Add new patch number below this line */
+ /**/
+ 335,
/**/
--
hundred-and-one symptoms of being an internet addict:
138. You develop a liking for cold coffee.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///