fix(api): inconsistent scrolling when deleting before topline (#36301)

Problem:  Inconsistent scrolling when deleting before topline with API.
Solution: Only special-case inserting just before topline, not deleting.
This commit is contained in:
zeertzjq
2025-10-27 07:53:15 +08:00
committed by GitHub
parent 2407833ba1
commit d707ccf988
2 changed files with 237 additions and 3 deletions

View File

@@ -1323,9 +1323,10 @@ void mark_adjust_buf(buf_T *buf, linenr_T line1, linenr_T line2, linenr_T amount
win->w_topline += amount;
}
win->w_topfill = 0;
// api: display new line if inserted right at topline
// TODO(bfredl): maybe always?
} else if (amount_after && win->w_topline > line2 + (by_api ? 1 : 0)) {
} else if (amount_after
// api: display new line if inserted right at topline
// TODO(bfredl): maybe always?
&& win->w_topline > line2 + (by_api && line2 < line1 ? 1 : 0)) {
win->w_topline += amount_after;
win->w_topfill = 0;
}