fix(mark): mark without a view restores at topline #19224

For a local mark without a view, currently trying to restore its view
will put the cursor at topline, which is not the correct behavior.
Initialize `topline_offset` to `MAXLNUM` instead to fix this.
This commit is contained in:
zeertzjq
2022-07-05 04:28:14 +08:00
committed by GitHub
parent 1803b0ffd7
commit 826fe56f5c
3 changed files with 32 additions and 1 deletions

View File

@@ -607,6 +607,8 @@ void mark_view_restore(fmark_T *fm)
{
if (fm != NULL && fm->view.topline_offset >= 0) {
linenr_T topline = fm->mark.lnum - fm->view.topline_offset;
// If the mark does not have a view, topline_offset is MAXLNUM,
// and this check can prevent restoring mark view in that case.
if (topline >= 1) {
set_topline(curwin, topline);
}