Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
29300:70a0db5f366d | 29301:fb375f0c6ea7 |
---|---|
4717 } | 4717 } |
4718 | 4718 |
4719 if (pt != NULL) | 4719 if (pt != NULL) |
4720 { | 4720 { |
4721 char_u *what = tv_get_string(&argvars[1]); | 4721 char_u *what = tv_get_string(&argvars[1]); |
4722 char_u *n; | |
4723 | 4722 |
4724 if (STRCMP(what, "func") == 0 || STRCMP(what, "name") == 0) | 4723 if (STRCMP(what, "func") == 0 || STRCMP(what, "name") == 0) |
4725 { | 4724 { |
4725 char_u *name = partial_name(pt); | |
4726 | |
4726 rettv->v_type = (*what == 'f' ? VAR_FUNC : VAR_STRING); | 4727 rettv->v_type = (*what == 'f' ? VAR_FUNC : VAR_STRING); |
4727 n = partial_name(pt); | 4728 if (name == NULL) |
4728 if (n == NULL) | |
4729 rettv->vval.v_string = NULL; | 4729 rettv->vval.v_string = NULL; |
4730 else | 4730 else |
4731 { | 4731 { |
4732 rettv->vval.v_string = vim_strsave(n); | |
4733 if (rettv->v_type == VAR_FUNC) | 4732 if (rettv->v_type == VAR_FUNC) |
4734 func_ref(rettv->vval.v_string); | 4733 func_ref(name); |
4734 if (*what == 'n' && pt->pt_name == NULL | |
4735 && pt->pt_func != NULL) | |
4736 // use <SNR> instead of the byte code | |
4737 name = printable_func_name(pt->pt_func); | |
4738 rettv->vval.v_string = vim_strsave(name); | |
4735 } | 4739 } |
4736 } | 4740 } |
4737 else if (STRCMP(what, "dict") == 0) | 4741 else if (STRCMP(what, "dict") == 0) |
4738 { | 4742 { |
4739 what_is_dict = TRUE; | 4743 what_is_dict = TRUE; |