Mercurial > vim
diff src/evalfunc.c @ 29301:fb375f0c6ea7 v8.2.5167
patch 8.2.5167: get(Fn, 'name') on funcref returns special byte code
Commit: https://github.com/vim/vim/commit/1ae8c262df7083dfb4b41485508951c50eccc84c
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 27 11:45:52 2022 +0100
patch 8.2.5167: get(Fn, 'name') on funcref returns special byte code
Problem: get(Fn, 'name') on funcref returns special byte code.
Solution: Use the printable name.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 27 Jun 2022 13:00:07 +0200 |
parents | f27ec19f2034 |
children | fcf524e1e97e |
line wrap: on
line diff
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -4719,19 +4719,23 @@ f_get(typval_T *argvars, typval_T *rettv if (pt != NULL) { char_u *what = tv_get_string(&argvars[1]); - char_u *n; if (STRCMP(what, "func") == 0 || STRCMP(what, "name") == 0) { + char_u *name = partial_name(pt); + rettv->v_type = (*what == 'f' ? VAR_FUNC : VAR_STRING); - n = partial_name(pt); - if (n == NULL) + if (name == NULL) rettv->vval.v_string = NULL; else { - rettv->vval.v_string = vim_strsave(n); if (rettv->v_type == VAR_FUNC) - func_ref(rettv->vval.v_string); + func_ref(name); + if (*what == 'n' && pt->pt_name == NULL + && pt->pt_func != NULL) + // use <SNR> instead of the byte code + name = printable_func_name(pt->pt_func); + rettv->vval.v_string = vim_strsave(name); } } else if (STRCMP(what, "dict") == 0)