1
0
forked from aniani/vim

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 #11661)
This commit is contained in:
Bram Moolenaar
2022-12-05 16:23:24 +00:00
parent 23526d2539
commit 99d19438ca
3 changed files with 10 additions and 0 deletions

View File

@@ -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);

View File

@@ -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

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1011,
/**/
1010,
/**/