# HG changeset patch # User Bram Moolenaar # Date 1670257806 -3600 # Node ID 45a03dd92f28426cfc28c5d55937b19ef03c01f4 # Parent 81fbd5f34ee719718fadc7c16df7e92b260ba4fc patch 9.0.1011: ml_get error when using screenpos() Commit: https://github.com/vim/vim/commit/99d19438cabaf13074229d9a32e3a4af9ce98744 Author: Bram Moolenaar Date: Mon Dec 5 16:23:24 2022 +0000 patch 9.0.1011: ml_get error when using screenpos() Problem: ml_get error when using screenpos(). Solution: Give an error for the line number. (closes https://github.com/vim/vim/issues/11661) diff --git a/src/move.c b/src/move.c --- a/src/move.c +++ b/src/move.c @@ -1500,6 +1500,11 @@ f_screenpos(typval_T *argvars UNUSED, ty 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 --- 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 --- 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,