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 void
f_getbufline(typval_T *argvars, typval_T *rettv) f_getbufline(typval_T *argvars, typval_T *rettv)
{ {
linenr_T lnum; linenr_T lnum = 1;
linenr_T end; linenr_T end = 1;
buf_T *buf; buf_T *buf;
buf = tv_get_buf_from_arg(&argvars[0]); buf = tv_get_buf_from_arg(&argvars[0]);
if (buf != NULL)
{
lnum = tv_get_lnum_buf(&argvars[1], buf); lnum = tv_get_lnum_buf(&argvars[1], buf);
if (argvars[2].v_type == VAR_UNKNOWN) if (argvars[2].v_type == VAR_UNKNOWN)
end = lnum; end = lnum;
else else
end = tv_get_lnum_buf(&argvars[2], buf); end = tv_get_lnum_buf(&argvars[2], buf);
}
get_buffer_lines(buf, lnum, end, TRUE, rettv); get_buffer_lines(buf, lnum, end, TRUE, rettv);
} }

View File

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

View File

@ -750,6 +750,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 */
/**/
1888,
/**/ /**/
1887, 1887,
/**/ /**/