From 35ed79a9150fed877e660395c64d6659bf0a07ec Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Sat, 29 Apr 2023 00:34:09 +0200 Subject: [PATCH] vim-patch:9.0.1435: scrolling too many lines when 'wrap' and 'diff' are set Problem: Scrolling too many lines when 'wrap' and 'diff' are set. Solution: Only scroll by screenlines for 'diff' when 'wrap' is not set. (closes vim/vim#12211) https://github.com/vim/vim/commit/38d867f041349e1400c2cce9cac06f59ae6ccbb1 Co-authored-by: Bram Moolenaar --- src/nvim/move.c | 2 +- test/old/testdir/test_diffmode.vim | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/nvim/move.c b/src/nvim/move.c index 69245f2a67..b597853c13 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1320,7 +1320,7 @@ static int scrolling_screenlines(bool byfold) { return (curwin->w_p_wrap && curwin->w_p_sms) || (byfold && hasAnyFolding(curwin)) - || curwin->w_p_diff; + || (curwin->w_p_diff && !curwin->w_p_wrap); } /// Scroll the current window up by "line_count" logical lines. "CTRL-E" diff --git a/test/old/testdir/test_diffmode.vim b/test/old/testdir/test_diffmode.vim index 0049398776..ac90aaaa02 100644 --- a/test/old/testdir/test_diffmode.vim +++ b/test/old/testdir/test_diffmode.vim @@ -1605,6 +1605,21 @@ func Test_diff_scroll() call delete('Xright') endfunc +" This was scrolling too many lines. +func Test_diff_scroll_wrap_on() + 20new + 40vsplit + call setline(1, map(range(1, 9), 'repeat(v:val, 200)')) + setlocal number diff so=0 + redraw + normal! jj + call assert_equal(1, winsaveview().topline) + normal! j + call assert_equal(2, winsaveview().topline) + bwipe! + bwipe! +endfunc + " This was trying to update diffs for a buffer being closed func Test_diff_only() silent! lfile