vim-patch:9.1.0822: topline might be changed in diff mode unexpectedly (#30988)

Problem:  topline might be changed in diff mode unexpectedly
          (Jaehwang Jung)
Solution: do not re-calculate topline, when using line() func
          in diff mode.

fixes: vim/vim#15812
closes: vim/vim#15950

05a40e07c2

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2024-10-30 09:05:11 +08:00
committed by GitHub
parent ff93cccbc1
commit 05d9e6a9e8
3 changed files with 141 additions and 0 deletions

View File

@@ -4351,9 +4351,17 @@ static void f_line(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (wp != NULL && tp != NULL) {
switchwin_T switchwin;
if (switch_win_noblock(&switchwin, wp, tp, true) == OK) {
// in diff mode, prevent that the window scrolls
// and keep the topline
if (curwin->w_p_diff && switchwin.sw_curwin->w_p_diff) {
skip_update_topline = true;
}
check_cursor(curwin);
fp = var2fpos(&argvars[0], true, &fnum, false);
}
if (curwin->w_p_diff && switchwin.sw_curwin->w_p_diff) {
skip_update_topline = false;
}
restore_win_noblock(&switchwin, true);
}
} else {