commit 6c7a5eff1dd4ba5940d83159349396101621abd1
parent e1aceb0068be6563bad2cbf43e5ee549eddbceef
Author: zeertzjq <zeertzjq@outlook.com>
Date: Mon, 22 Dec 2025 11:45:34 +0800
Merge pull request #37041 from janlazo/vim-8.2.1667
vim-patch:8.2.{223,1667,2992,3377,3383,3431,3657,4548}
Diffstat:
4 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/src/nvim/cmdexpand_defs.h b/src/nvim/cmdexpand_defs.h
@@ -102,6 +102,7 @@ enum {
EXPAND_MAPCLEAR,
EXPAND_ARGLIST,
EXPAND_DIFF_BUFFERS,
+ // EXPAND_DISASSEMBLE,
EXPAND_BREAKPOINT,
EXPAND_SCRIPTNAMES,
EXPAND_RUNTIME,
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
@@ -596,6 +596,7 @@ int get_func_tv(const char *name, int len, typval_T *rettv, char **arg, evalarg_
return ret;
}
+// fixed buffer length for fname_trans_sid()
#define FLEN_FIXED 40
/// Check whether function name starts with <SID> or s:
@@ -717,16 +718,24 @@ ufunc_T *find_func(const char *name)
return NULL;
}
+/// @return true if "ufunc" is a global function.
+static bool func_is_global(const ufunc_T *ufunc)
+ FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE
+{
+ return (uint8_t)ufunc->uf_name[0] != K_SPECIAL;
+}
+
/// Copy the function name of "fp" to buffer "buf".
/// "buf" must be able to hold the function name plus three bytes.
/// Takes care of script-local function names.
-static int cat_func_name(char *buf, size_t bufsize, ufunc_T *fp)
+static int cat_func_name(char *buf, size_t bufsize, const ufunc_T *fp)
+ FUNC_ATTR_NONNULL_ALL
{
int len = -1;
size_t uflen = fp->uf_namelen;
assert(uflen > 0);
- if ((uint8_t)fp->uf_name[0] == K_SPECIAL && uflen > 3) {
+ if (!func_is_global(fp) && uflen > 3) {
len = snprintf(buf, bufsize, "<SNR>%s", fp->uf_name + 3);
} else {
len = snprintf(buf, bufsize, "%s", fp->uf_name);
@@ -1362,14 +1371,16 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
}
/// There are two kinds of function names:
-/// 1. ordinary names, function defined with :function
-/// 2. numbered functions and lambdas
+/// 1. ordinary names, function defined with :function;
+/// can start with "<SNR>123_" literally or with K_SPECIAL.
+/// 2. Numbered functions and lambdas: "<lambda>123"
/// For the first we only count the name stored in func_hashtab as a reference,
/// using function() does not count as a reference, because the function is
/// looked up by name.
static bool func_name_refcount(const char *name)
+ FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE
{
- return isdigit((uint8_t)(*name)) || *name == '<';
+ return isdigit((uint8_t)(*name)) || (name[0] == '<' && name[1] == 'l');
}
/// Check the argument count for user function "fp".
diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim
@@ -1307,6 +1307,26 @@ func Test_cmdline_complete_various()
call feedkeys(":topleft new\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal("\"topleft new", @:)
+ " completion for the :disassemble command
+ " call feedkeys(":disas deb\<C-A>\<C-B>\"\<CR>", 'xt')
+ " call assert_equal("\"disas debug", @:)
+ " call feedkeys(":disas pro\<C-A>\<C-B>\"\<CR>", 'xt')
+ " call assert_equal("\"disas profile", @:)
+ " call feedkeys(":disas debug Test_cmdline_complete_var\<C-A>\<C-B>\"\<CR>", 'xt')
+ " call assert_equal("\"disas debug Test_cmdline_complete_various", @:)
+ " call feedkeys(":disas profile Test_cmdline_complete_var\<C-A>\<C-B>\"\<CR>", 'xt')
+ " call assert_equal("\"disas profile Test_cmdline_complete_various", @:)
+ " call feedkeys(":disas Test_cmdline_complete_var\<C-A>\<C-B>\"\<CR>", 'xt')
+ " call assert_equal("\"disas Test_cmdline_complete_various", @:)
+
+ " call feedkeys(":disas s:WeirdF\<C-A>\<C-B>\"\<CR>", 'xt')
+ " call assert_match('"disas <SNR>\d\+_WeirdFunc', @:)
+
+ " call feedkeys(":disas \<S-Tab>\<C-B>\"\<CR>", 'xt')
+ " call assert_match('"disas <SNR>\d\+_', @:)
+ " call feedkeys(":disas debug \<S-Tab>\<C-B>\"\<CR>", 'xt')
+ " call assert_match('"disas debug <SNR>\d\+_', @:)
+
" completion for the :match command
call feedkeys(":match Search /pat/\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal("\"match Search /pat/\<C-A>", @:)
diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim
@@ -436,6 +436,29 @@ func Test_Debugger_breakadd_expr()
call StopVimInTerminal(buf)
endfunc
+" def Test_Debugger_break_at_return()
+" var lines =<< trim END
+" vim9script
+" def g:GetNum(): number
+" return 1
+" + 2
+" + 3
+" enddef
+" breakadd func GetNum
+" END
+" writefile(lines, 'Xtest.vim')
+"
+" # Start Vim in a terminal
+" var buf = RunVimInTerminal('-S Xtest.vim', {wait_for_ruler: 0})
+" call TermWait(buf)
+"
+" RunDbgCmd(buf, ':call GetNum()',
+" ['line 1: return 1 + 2 + 3'], {match: 'pattern'})
+"
+" call StopVimInTerminal(buf)
+" call delete('Xtest.vim')
+" enddef
+
func Test_Backtrace_Through_Source()
CheckRunVimInTerminal
CheckCWD