fix(float): wrong position when bufpos is set

Problem: when lnum in bufpos is out of range the position of float is wired.

Solution: avoid the height value out of buffer line range.
This commit is contained in:
glepnir
2024-04-20 12:01:28 +08:00
parent 4d52b0cf67
commit 5f18dd3013
3 changed files with 40 additions and 2 deletions

View File

@ -827,7 +827,8 @@ void ui_ext_win_position(win_T *wp, bool validate)
row += row_off;
col += col_off;
if (c.bufpos.lnum >= 0) {
pos_T pos = { c.bufpos.lnum + 1, c.bufpos.col, 0 };
int lnum = MIN(c.bufpos.lnum + 1, win->w_buffer->b_ml.ml_line_count);
pos_T pos = { lnum, c.bufpos.col, 0 };
int trow, tcol, tcolc, tcole;
textpos2screenpos(win, &pos, &trow, &tcol, &tcolc, &tcole, true);
row += trow - 1;