Skip to content

Commit b2ac7d0

Browse files
committed
patch 8.2.2670: Vim9: error for append(0, text)
Problem: Vim9: error for append(0, text). Solution: Check for negative number. (closes #8022)
1 parent df749a2 commit b2ac7d0

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/testdir/test_vim9_builtin.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ def Test_append()
123123
var res2: bool = append(3, 'two')
124124
assert_equal(false, res2)
125125
assert_equal(['0', 'one', '1', 'two', '2'], getline(1, 6))
126+
127+
append(0, 'zero')
128+
assert_equal('zero', getline(1))
129+
bwipe!
126130
enddef
127131

128132
def Test_balloon_show()

src/typval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ tv_get_lnum(typval_T *argvars)
16211621

16221622
if (argvars[0].v_type != VAR_STRING || !in_vim9script())
16231623
lnum = (linenr_T)tv_get_number_chk(&argvars[0], NULL);
1624-
if (lnum <= 0) // no valid number, try using arg like line()
1624+
if (lnum < 0) // no valid number, try using arg like line()
16251625
{
16261626
int fnum;
16271627
pos_T *fp = var2fpos(&argvars[0], TRUE, &fnum, FALSE);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2670,
753755
/**/
754756
2669,
755757
/**/

0 commit comments

Comments
 (0)