diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 18 | ||||
-rw-r--r-- | src/nvim/testdir/test_partial.vim | 15 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
3 files changed, 27 insertions, 8 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index be1eb3ef1c..2139d651cd 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -9706,14 +9706,24 @@ static void f_get(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (di != NULL) tv = &di->di_tv; } - } else if (argvars[0].v_type == VAR_PARTIAL) { - partial_T *pt = argvars[0].vval.v_partial; + } else if (argvars[0].v_type == VAR_PARTIAL + || argvars[0].v_type == VAR_FUNC) { + partial_T *pt; + partial_T fref_pt; + + if (argvars[0].v_type == VAR_PARTIAL) { + pt = argvars[0].vval.v_partial; + } else { + memset(&fref_pt, 0, sizeof(fref_pt)); + fref_pt.pt_name = argvars[0].vval.v_string; + pt = &fref_pt; + } if (pt != NULL) { char_u *what = get_tv_string(&argvars[1]); - if (STRCMP(what, "func") == 0) { - rettv->v_type = VAR_STRING; + if (STRCMP(what, "func") == 0 || STRCMP(what, "name") == 0) { + rettv->v_type = (*what == 'f' ? VAR_FUNC : VAR_STRING); if (pt->pt_name != NULL) { rettv->vval.v_string = vim_strsave(pt->pt_name); } diff --git a/src/nvim/testdir/test_partial.vim b/src/nvim/testdir/test_partial.vim index 7562c7fd2a..f97d283022 100644 --- a/src/nvim/testdir/test_partial.vim +++ b/src/nvim/testdir/test_partial.vim @@ -250,9 +250,18 @@ endfunc func Test_get_partial_items() let dict = {'name': 'hello'} - let Cb = function('MyDictFunc', ["foo", "bar"], dict) - call assert_equal('MyDictFunc', get(Cb, 'func')) - call assert_equal(["foo", "bar"], get(Cb, 'args')) + let args = ["foo", "bar"] + let Func = function('MyDictFunc') + let Cb = function('MyDictFunc', args, dict) + + call assert_equal(Func, get(Cb, 'func')) + call assert_equal('MyDictFunc', get(Cb, 'name')) + call assert_equal(args, get(Cb, 'args')) call assert_equal(dict, get(Cb, 'dict')) call assert_fails('call get(Cb, "xxx")', 'E475:') + + call assert_equal(Func, get(Func, 'func')) + call assert_equal('MyDictFunc', get(Func, 'name')) + call assert_equal([], get(Func, 'args')) + call assert_true(empty( get(Func, 'dict'))) endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 88c0185f57..e391c61c23 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -598,7 +598,7 @@ static int included_patches[] = { // 1845 NA // 1844, // 1843 NA - // 1842, + 1842, // 1841, 1840, // 1839, |