1
0
forked from aniani/vim

patch 8.2.2670: Vim9: error for append(0, text)

Problem:    Vim9: error for append(0, text).
Solution:   Check for negative number. (closes #8022)
This commit is contained in:
Bram Moolenaar
2021-03-28 15:46:16 +02:00
parent df749a2b9c
commit b2ac7d0663
3 changed files with 7 additions and 1 deletions

View File

@@ -123,6 +123,10 @@ def Test_append()
var res2: bool = append(3, 'two') var res2: bool = append(3, 'two')
assert_equal(false, res2) assert_equal(false, res2)
assert_equal(['0', 'one', '1', 'two', '2'], getline(1, 6)) assert_equal(['0', 'one', '1', 'two', '2'], getline(1, 6))
append(0, 'zero')
assert_equal('zero', getline(1))
bwipe!
enddef enddef
def Test_balloon_show() def Test_balloon_show()

View File

@@ -1621,7 +1621,7 @@ tv_get_lnum(typval_T *argvars)
if (argvars[0].v_type != VAR_STRING || !in_vim9script()) if (argvars[0].v_type != VAR_STRING || !in_vim9script())
lnum = (linenr_T)tv_get_number_chk(&argvars[0], NULL); lnum = (linenr_T)tv_get_number_chk(&argvars[0], NULL);
if (lnum <= 0) // no valid number, try using arg like line() if (lnum < 0) // no valid number, try using arg like line()
{ {
int fnum; int fnum;
pos_T *fp = var2fpos(&argvars[0], TRUE, &fnum, FALSE); pos_T *fp = var2fpos(&argvars[0], TRUE, &fnum, FALSE);

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 */
/**/
2670,
/**/ /**/
2669, 2669,
/**/ /**/