aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-03 04:26:00 +0800
committerGitHub <noreply@github.com>2022-12-03 04:26:00 +0800
commit10c50d9f30138e7811789ba1c62f4c520cf04c8f (patch)
tree6be3628f7d152c1f703f59fa1050039c90244707 /src/nvim/eval.c
parent07e6296520fc83b1fdb287b5173494cdd0e9136f (diff)
parentafb3ff52ecafe2d5bd1239869124794bb2ac68b9 (diff)
downloadrneovim-10c50d9f30138e7811789ba1c62f4c520cf04c8f.tar.gz
rneovim-10c50d9f30138e7811789ba1c62f4c520cf04c8f.tar.bz2
rneovim-10c50d9f30138e7811789ba1c62f4c520cf04c8f.zip
Merge pull request #21266 from zeertzjq/vim-8.2.3889
vim-patch:8.2.3889,9.0.{0805,0990}
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index c4afd6934c..6d8f4d092c 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -5018,18 +5018,11 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref)
int arg_idx = 0;
list_T *list = NULL;
if (strncmp(s, "s:", 2) == 0 || strncmp(s, "<SID>", 5) == 0) {
- char sid_buf[25];
- int off = *s == 's' ? 2 : 5;
-
// Expand s: and <SID> into <SNR>nr_, so that the function can
// also be called from another script. Using trans_function_name()
// would also work, but some plugins depend on the name being
// printable text.
- snprintf(sid_buf, sizeof(sid_buf), "<SNR>%" PRId64 "_",
- (int64_t)current_sctx.sc_sid);
- name = xmalloc(strlen(sid_buf) + strlen(s + off) + 1);
- STRCPY(name, sid_buf);
- STRCAT(name, s + off);
+ name = get_scriptlocal_funcname(s);
} else {
name = xstrdup(s);
}
@@ -5517,6 +5510,7 @@ void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv, bool retlist
}
}
+/// Get a callback from "arg". It can be a Funcref or a function name.
bool callback_from_typval(Callback *const callback, typval_T *const arg)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{
@@ -5538,8 +5532,14 @@ bool callback_from_typval(Callback *const callback, typval_T *const arg)
callback->type = kCallbackNone;
callback->data.funcref = NULL;
} else {
- func_ref((char_u *)name);
- callback->data.funcref = xstrdup(name);
+ callback->data.funcref = NULL;
+ if (arg->v_type == VAR_STRING) {
+ callback->data.funcref = get_scriptlocal_funcname(name);
+ }
+ if (callback->data.funcref == NULL) {
+ callback->data.funcref = xstrdup(name);
+ }
+ func_ref((char_u *)callback->data.funcref);
callback->type = kCallbackFuncref;
}
} else if (nlua_is_table_from_lua(arg)) {