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

patch 8.2.1562: Vim9: error when using "%" where a buffer is expected

Problem:    Vim9: error when using "%" where a buffer is expected.
Solution:   Add tv_get_buf_from_arg(). (closes #6814)
This commit is contained in:
Bram Moolenaar
2020-09-01 23:06:01 +02:00
parent 81fcb67fb3
commit 3767e3a330
5 changed files with 32 additions and 29 deletions

View File

@@ -1562,4 +1562,23 @@ tv_get_buf(typval_T *tv, int curtab_only)
return buf;
}
/*
* Like tv_get_buf() but give an error message is the type is wrong.
*/
buf_T *
tv_get_buf_from_arg(typval_T *tv)
{
buf_T *buf;
++emsg_off;
buf = tv_get_buf(tv, FALSE);
--emsg_off;
if (buf == NULL
&& tv->v_type != VAR_NUMBER
&& tv->v_type != VAR_STRING)
// issue errmsg for type error
(void)tv_get_number(tv);
return buf;
}
#endif // FEAT_EVAL