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.
(cherry picked from commit 3341ab0776)
This commit is contained in:
luukvbaal
2025-04-14 13:19:07 +02:00
committed by github-actions[bot]
parent e4007551c4
commit 4d87229789
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);