]> granicus.if.org Git - vim/commitdiff
patch 8.2.1563: Vim9: error when using '%" with setbufvar() r getbufvar() v8.2.1563
authorBram Moolenaar <Bram@vim.org>
Tue, 1 Sep 2020 21:16:32 +0000 (23:16 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 1 Sep 2020 21:16:32 +0000 (23:16 +0200)
Problem:    Vim9: error when using '%" with setbufvar() or getbufvar().
Solution:   Use tv_get_buf_from_arg(). (closes #6816)

src/evalvars.c
src/testdir/test_vim9_func.vim
src/version.c

index ecd0ce6bd5b77ba31823631e5f2b8e1ee33f0aa3..efab6ab16331bbb60f3e0afb4ff0b34b3f6fbe5e 100644 (file)
@@ -3662,10 +3662,8 @@ f_getbufvar(typval_T *argvars, typval_T *rettv)
     dictitem_T *v;
     int                done = FALSE;
 
-    (void)tv_get_number(&argvars[0]);      // issue errmsg if type error
     varname = tv_get_string_chk(&argvars[1]);
-    ++emsg_off;
-    buf = tv_get_buf(&argvars[0], FALSE);
+    buf = tv_get_buf_from_arg(&argvars[0]);
 
     rettv->v_type = VAR_STRING;
     rettv->vval.v_string = NULL;
@@ -3717,8 +3715,6 @@ f_getbufvar(typval_T *argvars, typval_T *rettv)
     if (!done && argvars[2].v_type != VAR_UNKNOWN)
        // use the default value
        copy_tv(&argvars[2], rettv);
-
-    --emsg_off;
 }
 
 /*
@@ -3789,9 +3785,8 @@ f_setbufvar(typval_T *argvars, typval_T *rettv UNUSED)
 
     if (check_secure())
        return;
-    (void)tv_get_number(&argvars[0]);      // issue errmsg if type error
     varname = tv_get_string_chk(&argvars[1]);
-    buf = tv_get_buf(&argvars[0], FALSE);
+    buf = tv_get_buf_from_arg(&argvars[0]);
     varp = &argvars[2];
 
     if (buf != NULL && varname != NULL && varp != NULL)
index 0575836443bc28946cd5ebc48acbba15dcc1808d..09c84576ded7c42a3f2e9a195d47fd559ca84773 100644 (file)
@@ -1426,6 +1426,9 @@ def Test_setbufvar()
    settabwinvar(1, 1, '&ts', 15)
    assert_equal(15, &ts)
    setlocal ts=8
+
+   setbufvar('%', 'myvar', 123)
+   assert_equal(123, getbufvar('%', 'myvar'))
 enddef
 
 def Test_setreg()
index f2d89f67287490c625f2c532a3451bc2ca6fab6e..d606f1ec92dbd0de46d33bd6c0bbdb6ae7cf00a1 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1563,
 /**/
     1562,
 /**/