Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
9109:e1d99f1c4436 | 9110:6d3888e2232c |
---|---|
12421 di = dict_find(d, get_tv_string(&argvars[1]), -1); | 12421 di = dict_find(d, get_tv_string(&argvars[1]), -1); |
12422 if (di != NULL) | 12422 if (di != NULL) |
12423 tv = &di->di_tv; | 12423 tv = &di->di_tv; |
12424 } | 12424 } |
12425 } | 12425 } |
12426 else if (argvars[0].v_type == VAR_PARTIAL) | |
12427 { | |
12428 partial_T *pt = argvars[0].vval.v_partial; | |
12429 | |
12430 if (pt != NULL) | |
12431 { | |
12432 char_u *what = get_tv_string(&argvars[1]); | |
12433 | |
12434 if (STRCMP(what, "func") == 0) | |
12435 { | |
12436 rettv->v_type = VAR_STRING; | |
12437 if (pt->pt_name == NULL) | |
12438 rettv->vval.v_string = NULL; | |
12439 else | |
12440 rettv->vval.v_string = vim_strsave(pt->pt_name); | |
12441 } | |
12442 else if (STRCMP(what, "dict") == 0) | |
12443 { | |
12444 rettv->v_type = VAR_DICT; | |
12445 rettv->vval.v_dict = pt->pt_dict; | |
12446 if (pt->pt_dict != NULL) | |
12447 ++pt->pt_dict->dv_refcount; | |
12448 } | |
12449 else if (STRCMP(what, "args") == 0) | |
12450 { | |
12451 rettv->v_type = VAR_LIST; | |
12452 if (rettv_list_alloc(rettv) == OK) | |
12453 { | |
12454 int i; | |
12455 | |
12456 for (i = 0; i < pt->pt_argc; ++i) | |
12457 list_append_tv(rettv->vval.v_list, &pt->pt_argv[i]); | |
12458 } | |
12459 } | |
12460 else | |
12461 EMSG2(_(e_invarg2), what); | |
12462 return; | |
12463 } | |
12464 } | |
12426 else | 12465 else |
12427 EMSG2(_(e_listdictarg), "get()"); | 12466 EMSG2(_(e_listdictarg), "get()"); |
12428 | 12467 |
12429 if (tv == NULL) | 12468 if (tv == NULL) |
12430 { | 12469 { |