0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.1563: Vim9: error when using '%" with setbufvar() r getbufvar()

Problem:    Vim9: error when using '%" with setbufvar() or getbufvar().
Solution:   Use tv_get_buf_from_arg(). (closes #6816)
This commit is contained in:
Bram Moolenaar 2020-09-01 23:16:32 +02:00
parent 3767e3a330
commit 6f84b6db10
3 changed files with 7 additions and 7 deletions

View 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)

View 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()

View File

@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1563,
/**/
1562,
/**/