diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-10-22 18:23:38 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-10-22 18:23:38 +0200 |
commit | e6e70a10f118ecfa9df2425e8724bc009bd09929 (patch) | |
tree | 6c52ba48eb706339ab8e1d09d5bde94a4206e0ef /src | |
parent | 15ab48f088842de512ca5f13aa39a4dc7cac8477 (diff) |
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an errorv8.2.1888
Problem: Vim9: Getbufline(-1, 1, '$') gives an error.
Solution: Return an empty list. (closes #7180)
Diffstat (limited to 'src')
-rw-r--r-- | src/evalbuffer.c | 18 | ||||
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 2 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 14 insertions, 8 deletions
diff --git a/src/evalbuffer.c b/src/evalbuffer.c index 34155b9cbb..eabe626f50 100644 --- a/src/evalbuffer.c +++ b/src/evalbuffer.c @@ -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); } diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index e3d7bb628d..d6891a81b3 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -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 diff --git a/src/version.c b/src/version.c index 16e7a9fcd0..04bc2483d2 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1888, +/**/ 1887, /**/ 1886, |