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:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1011,
|
||||
/**/
|
||||
1010,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user