From a40a7cf24f5a57963388cef5c5472ab4047d568f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 17 Aug 2014 22:19:38 +0000 Subject: [PATCH] vim-patch:7.4.329 #1079 Problem: When moving the cursor and then switching to another window the previous window isn't scrolled. (Yukihiro Nakadaira) Solution: Call update_topline() before leaving the window. (Christian Brabandt) https://code.google.com/p/vim/source/detail?r=018df65085f8 --- src/nvim/version.c | 2 +- src/nvim/window.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/nvim/version.c b/src/nvim/version.c index f2a85d5b69..246ce02f1f 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -266,7 +266,7 @@ static int included_patches[] = { //332 NA 331, //330, - //329, + 329, 328, 327, //326 NA 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;