diff options
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r-- | src/nvim/window.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c index ca56c9d5d5..755ecb0ef1 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -3396,12 +3396,19 @@ static void win_enter_ext(win_T *wp, bool undo_sync, int curwin_invalid, int tri return; } - /* sync undo before leaving the current buffer */ - if (undo_sync && curbuf != wp->w_buffer) + // sync undo before leaving the current buffer + if (undo_sync && curbuf != wp->w_buffer) { u_sync(FALSE); - /* may have to copy the buffer options when 'cpo' contains 'S' */ - if (wp->w_buffer != curbuf) + } + + // Might need to scroll the old window before switching, e.g., when the + // cursor was moved. + update_topline(); + + // may have to copy the buffer options when 'cpo' contains 'S' + if (wp->w_buffer != curbuf) { buf_copy_options(wp->w_buffer, BCO_ENTER | BCO_NOHELP); + } if (!curwin_invalid) { prevwin = curwin; /* remember for CTRL-W p */ curwin->w_redr_status = TRUE; |