fix(marks): clamp conceal_lines corrected line number #33464

Problem:  Line number corrected for conceal_lines may be set beyond eob
          when the last buffer line is concealed, causing ml_get errors.

Solution: Avoid setting line number beyond eob.
This commit is contained in:
luukvbaal
2025-04-14 13:19:07 +02:00
committed by GitHub
parent aa47c8efa9
commit 3341ab0776
3 changed files with 14 additions and 4 deletions

View File

@@ -1705,7 +1705,8 @@ static void win_update(win_T *wp)
// incurring scrolling even though wp->w_topline is still the same.
// Compare against an adjusted topline instead:
linenr_T topline_conceal = wp->w_topline;
while (decor_conceal_line(wp, topline_conceal - 1, false)) {
while (topline_conceal < buf->b_ml.ml_line_count
&& decor_conceal_line(wp, topline_conceal - 1, false)) {
topline_conceal++;
hasFolding(wp, topline_conceal, NULL, &topline_conceal);
}
@@ -2320,6 +2321,7 @@ static void win_update(win_T *wp)
// Adjust "wl_lastlnum" for concealed lines below the last line in the window.
while (row == wp->w_grid.rows
&& wp->w_lines[idx].wl_lastlnum < buf->b_ml.ml_line_count
&& decor_conceal_line(wp, wp->w_lines[idx].wl_lastlnum, false)) {
wp->w_lines[idx].wl_lastlnum++;
hasFolding(wp, wp->w_lines[idx].wl_lastlnum, NULL, &wp->w_lines[idx].wl_lastlnum);

View File

@@ -1661,7 +1661,8 @@ bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump)
}
// Mouse row reached, adjust lnum for concealed lines.
while (decor_conceal_line(win, lnum - 1, false)) {
while (lnum < win->w_buffer->b_ml.ml_line_count
&& decor_conceal_line(win, lnum - 1, false)) {
lnum++;
hasFolding(win, lnum, NULL, &lnum);
}