diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-12-05 16:23:24 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-12-05 16:23:24 +0000 |
commit | 99d19438cabaf13074229d9a32e3a4af9ce98744 (patch) | |
tree | 51b59e0f08a8092e461de4f9c373735a949e667f /src | |
parent | 23526d2539e8679ea8df14e3a018101dedc3f391 (diff) | |
download | vim-git-99d19438cabaf13074229d9a32e3a4af9ce98744.tar.gz |
patch 9.0.1011: ml_get error when using screenpos()v9.0.1011
Problem: ml_get error when using screenpos().
Solution: Give an error for the line number. (closes #11661)
Diffstat (limited to 'src')
-rw-r--r-- | src/move.c | 5 | ||||
-rw-r--r-- | src/testdir/test_cursor_func.vim | 3 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 10 insertions, 0 deletions
diff --git a/src/move.c b/src/move.c index 7a9ae3ea6..954a13714 100644 --- a/src/move.c +++ b/src/move.c @@ -1500,6 +1500,11 @@ f_screenpos(typval_T *argvars UNUSED, typval_T *rettv) return; pos.lnum = tv_get_number(&argvars[1]); + if (pos.lnum > wp->w_buffer->b_ml.ml_line_count) + { + semsg(_(e_invalid_line_number_nr), pos.lnum); + return; + } pos.col = tv_get_number(&argvars[2]) - 1; pos.coladd = 0; textpos2screenpos(wp, &pos, &row, &scol, &ccol, &ecol); diff --git a/src/testdir/test_cursor_func.vim b/src/testdir/test_cursor_func.vim index a48db15e6..8bdc956e2 100644 --- a/src/testdir/test_cursor_func.vim +++ b/src/testdir/test_cursor_func.vim @@ -167,6 +167,9 @@ func Test_screenpos_number() let pos = screenpos(winid, 1, 66) call assert_equal(winrow, pos.row) call assert_equal(wincol + 66 + 3, pos.col) + + call assert_fails('echo screenpos(0, 2, 1)', 'E966:') + close bwipe! endfunc diff --git a/src/version.c b/src/version.c index b8b346071..48bec3d9a 100644 --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1011, +/**/ 1010, /**/ 1009, |