1
0
forked from aniani/vim

patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error

Problem:    Vim9: Getbufline(-1, 1, '$') gives an error.
Solution:   Return an empty list. (closes #7180)
This commit is contained in:
Bram Moolenaar 2020-10-22 18:23:38 +02:00
parent 15ab48f088
commit e6e70a10f1
3 changed files with 14 additions and 8 deletions

View File

@ -717,17 +717,19 @@ get_buffer_lines(
void
f_getbufline(typval_T *argvars, typval_T *rettv)
{
linenr_T lnum;
linenr_T end;
linenr_T lnum = 1;
linenr_T end = 1;
buf_T *buf;
buf = tv_get_buf_from_arg(&argvars[0]);
lnum = tv_get_lnum_buf(&argvars[1], buf);
if (argvars[2].v_type == VAR_UNKNOWN)
end = lnum;
else
end = tv_get_lnum_buf(&argvars[2], buf);
if (buf != NULL)
{
lnum = tv_get_lnum_buf(&argvars[1], buf);
if (argvars[2].v_type == VAR_UNKNOWN)
end = lnum;
else
end = tv_get_lnum_buf(&argvars[2], buf);
}
get_buffer_lines(buf, lnum, end, TRUE, rettv);
}

View File

@ -242,6 +242,8 @@ def Test_getbufline()
var lines = ['aaa', 'bbb', 'ccc']
setbufline(buf, 1, lines)
getbufline('#', 1, '$')->assert_equal(lines)
getbufline(-1, '$', '$')->assert_equal([])
getbufline(-1, 1, '$')->assert_equal([])
bwipe!
enddef

View File

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