diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-09-01 23:06:01 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-09-01 23:06:01 +0200 |
commit | 3767e3a3302d745349eff8cfe45411f03e13de43 (patch) | |
tree | 03523354dd08a8bbdee8868d3e22213d10da2513 /src/typval.c | |
parent | 81fcb67fb32a12414512b72e691a1bbbff9f8511 (diff) | |
download | vim-git-3767e3a3302d745349eff8cfe45411f03e13de43.tar.gz |
patch 8.2.1562: Vim9: error when using "%" where a buffer is expectedv8.2.1562
Problem: Vim9: error when using "%" where a buffer is expected.
Solution: Add tv_get_buf_from_arg(). (closes #6814)
Diffstat (limited to 'src/typval.c')
-rw-r--r-- | src/typval.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/typval.c b/src/typval.c index d1732f2b7..c7cfd4116 100644 --- a/src/typval.c +++ b/src/typval.c @@ -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 |