Mercurial > vim
changeset 24258:8b4159943d9a v8.2.2670
patch 8.2.2670: Vim9: error for append(0, text)
Commit: https://github.com/vim/vim/commit/b2ac7d0663ef31a335c50c6afca042ed9ace5059
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 28 15:46:16 2021 +0200
patch 8.2.2670: Vim9: error for append(0, text)
Problem: Vim9: error for append(0, text).
Solution: Check for negative number. (closes https://github.com/vim/vim/issues/8022)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 28 Mar 2021 16:00:03 +0200 |
parents | 952600bbf45c |
children | b91a0ffa80f1 |
files | src/testdir/test_vim9_builtin.vim src/typval.c src/version.c |
diffstat | 3 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -123,6 +123,10 @@ def Test_append() var res2: bool = append(3, 'two') assert_equal(false, res2) assert_equal(['0', 'one', '1', 'two', '2'], getline(1, 6)) + + append(0, 'zero') + assert_equal('zero', getline(1)) + bwipe! enddef def Test_balloon_show()
--- a/src/typval.c +++ b/src/typval.c @@ -1621,7 +1621,7 @@ tv_get_lnum(typval_T *argvars) if (argvars[0].v_type != VAR_STRING || !in_vim9script()) 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; pos_T *fp = var2fpos(&argvars[0], TRUE, &fnum, FALSE);