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 vim/vim#11661)

99d19438ca

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2022-12-06 07:52:00 +08:00
parent 10af0549df
commit 0909d987fe
3 changed files with 9 additions and 0 deletions

View File

@@ -996,6 +996,10 @@ void f_screenpos(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
.col = (colnr_T)tv_get_number(&argvars[2]) - 1,
.coladd = 0
};
if (pos.lnum > wp->w_buffer->b_ml.ml_line_count) {
semsg(_(e_invalid_line_number_nr), pos.lnum);
return;
}
int row = 0;
int scol = 0, ccol = 0, ecol = 0;
textpos2screenpos(wp, &pos, &row, &scol, &ccol, &ecol, false);