Mercurial > vim
diff src/eval.c @ 9110:6d3888e2232c v7.4.1839
commit https://github.com/vim/vim/commit/2bbf8eff6fab16d86e7bcfc0da1962d31bec7891
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue May 24 18:37:12 2016 +0200
patch 7.4.1839
Problem: Cannot get the items stored in a partial.
Solution: Support using get() on a partial.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 24 May 2016 18:45:06 +0200 |
parents | d319453f62b3 |
children | 0cc48b3cd884 |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -12423,6 +12423,45 @@ f_get(typval_T *argvars, typval_T *rettv tv = &di->di_tv; } } + else if (argvars[0].v_type == VAR_PARTIAL) + { + partial_T *pt = argvars[0].vval.v_partial; + + if (pt != NULL) + { + char_u *what = get_tv_string(&argvars[1]); + + if (STRCMP(what, "func") == 0) + { + rettv->v_type = VAR_STRING; + if (pt->pt_name == NULL) + rettv->vval.v_string = NULL; + else + rettv->vval.v_string = vim_strsave(pt->pt_name); + } + else if (STRCMP(what, "dict") == 0) + { + rettv->v_type = VAR_DICT; + rettv->vval.v_dict = pt->pt_dict; + if (pt->pt_dict != NULL) + ++pt->pt_dict->dv_refcount; + } + else if (STRCMP(what, "args") == 0) + { + rettv->v_type = VAR_LIST; + if (rettv_list_alloc(rettv) == OK) + { + int i; + + for (i = 0; i < pt->pt_argc; ++i) + list_append_tv(rettv->vval.v_list, &pt->pt_argv[i]); + } + } + else + EMSG2(_(e_invarg2), what); + return; + } + } else EMSG2(_(e_listdictarg), "get()");