mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.1550: Vim9: bufname('%') gives an error
Problem: Vim9: bufname('%') gives an error. Solution: Only give an error for wrong argument type. (closes #6807)
This commit is contained in:
@@ -359,15 +359,20 @@ f_bufloaded(typval_T *argvars, typval_T *rettv)
|
|||||||
f_bufname(typval_T *argvars, typval_T *rettv)
|
f_bufname(typval_T *argvars, typval_T *rettv)
|
||||||
{
|
{
|
||||||
buf_T *buf;
|
buf_T *buf;
|
||||||
|
typval_T *tv = &argvars[0];
|
||||||
|
|
||||||
if (argvars[0].v_type == VAR_UNKNOWN)
|
if (tv->v_type == VAR_UNKNOWN)
|
||||||
buf = curbuf;
|
buf = curbuf;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(void)tv_get_number(&argvars[0]); // issue errmsg if type error
|
|
||||||
++emsg_off;
|
++emsg_off;
|
||||||
buf = tv_get_buf(&argvars[0], FALSE);
|
buf = tv_get_buf(tv, FALSE);
|
||||||
--emsg_off;
|
--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);
|
||||||
}
|
}
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
if (buf != NULL && buf->b_fname != NULL)
|
if (buf != NULL && buf->b_fname != NULL)
|
||||||
|
@@ -1435,6 +1435,14 @@ def Test_setreg()
|
|||||||
assert_equal(reginfo, getreginfo('a'))
|
assert_equal(reginfo, getreginfo('a'))
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_bufname()
|
||||||
|
split SomeFile
|
||||||
|
assert_equal('SomeFile', bufname('%'))
|
||||||
|
edit OtherFile
|
||||||
|
assert_equal('SomeFile', bufname('#'))
|
||||||
|
close
|
||||||
|
enddef
|
||||||
|
|
||||||
def Fibonacci(n: number): number
|
def Fibonacci(n: number): number
|
||||||
if n < 2
|
if n < 2
|
||||||
return n
|
return n
|
||||||
|
@@ -754,6 +754,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1550,
|
||||||
/**/
|
/**/
|
||||||
1549,
|
1549,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user