From 7629176fb11be234882c64e3bf92d97839301fe4 Mon Sep 17 00:00:00 2001 From: lonerover Date: Tue, 7 Feb 2017 15:46:19 +0800 Subject: vim-patch:7.4.2275 Problem: ":diffoff!" does not remove filler lines. Solution: Force a redraw and invalidate the cursor. (closes vim/vim#1014) https://github.com/vim/vim/commit/e67d546f3c691139e6d3d33f36724d98aec04c14 --- src/nvim/diff.c | 9 ++++++--- src/nvim/testdir/test_diffmode.vim | 16 ++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index aafd50687e..9cb0789400 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1154,10 +1154,13 @@ void ex_diffoff(exarg_T *eap) } foldUpdateAll(wp); - - // make sure topline is not halfway through a fold - changed_window_setting_win(wp); } + // remove filler lines + wp->w_topfill = 0; + + // make sure topline is not halfway a fold and cursor is + // invalidated + changed_window_setting_win(wp); // Note: 'sbo' is not restored, it's a global option. diff_buf_adjust(wp); diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim index 7666594862..5de394de8e 100644 --- a/src/nvim/testdir/test_diffmode.vim +++ b/src/nvim/testdir/test_diffmode.vim @@ -202,3 +202,19 @@ func Test_diffget_diffput() bwipe! enew! endfunc + +func Test_diffoff() + enew! + call setline(1, ['Two', 'Three']) + let normattr = screenattr(1, 1) + diffthis + botright vert new + call setline(1, ['One', '', 'Two', 'Three']) + diffthis + redraw + diffoff! + redraw + call assert_equal(normattr, screenattr(1, 1)) + bwipe! + bwipe! +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index e73b68b6e7..befcc918cc 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -165,7 +165,7 @@ static int included_patches[] = { // 2278 NA 2277, // 2276, - // 2275, + 2275, 2274, 2273, 2272, -- cgit From 67eae935575b85719f3292d428d9d5387e0d7fb8 Mon Sep 17 00:00:00 2001 From: lonerover Date: Tue, 7 Feb 2017 15:48:01 +0800 Subject: vim-patch:7.4.2279 Problem: Starting diff mode with the cursor in the last line might end up only showing one closed fold. (John Beckett) Solution: Scroll the window to show the same relative cursor position. https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028 --- src/nvim/diff.c | 7 +++++++ src/nvim/version.c | 2 +- src/nvim/window.c | 11 +++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 9cb0789400..5940dc55da 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1007,6 +1007,10 @@ void ex_diffsplit(exarg_T *eap) bufref_T old_curbuf; set_bufref(&old_curbuf, curbuf); + // Need to compute w_fraction when no redraw happened yet. + validate_cursor(); + set_fraction(curwin); + // don't use a new tab page, each tab page has its own diffs cmdmod.tab = 0; @@ -1032,6 +1036,9 @@ void ex_diffsplit(exarg_T *eap) curwin->w_cursor.lnum); } } + // Now that lines are folded scroll to show the cursor at the same + // relative position. + scroll_to_fraction(curwin, curwin->w_height); } } } diff --git a/src/nvim/version.c b/src/nvim/version.c index befcc918cc..ee2288e1b0 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -161,7 +161,7 @@ static int included_patches[] = { // 2282 NA // 2281 NA // 2280, - // 2279, + 2279, // 2278 NA 2277, // 2276, diff --git a/src/nvim/window.c b/src/nvim/window.c index 510f182353..28269e8889 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -4717,8 +4717,6 @@ void set_fraction(win_T *wp) */ void win_new_height(win_T *wp, int height) { - linenr_T lnum; - int sline, line_size; int prev_height = wp->w_height; /* Don't want a negative height. Happens when splitting a tiny window. @@ -4745,6 +4743,15 @@ void win_new_height(win_T *wp, int height) wp->w_height = height; wp->w_skipcol = 0; + scroll_to_fraction(wp, prev_height); +} + +void scroll_to_fraction(win_T *wp, int prev_height) +{ + linenr_T lnum; + int sline, line_size; + int height = wp->w_height; + /* Don't change w_topline when height is zero. Don't set w_topline when * 'scrollbind' is set and this isn't the current window. */ if (height > 0 -- cgit