]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1981: not being able to scroll up in diff mode v9.0.1981
authorzeertzjq <zeertzjq@outlook.com>
Wed, 4 Oct 2023 18:12:37 +0000 (20:12 +0200)
committerChristian Brabandt <cb@256bit.org>
Wed, 4 Oct 2023 18:12:37 +0000 (20:12 +0200)
Problem:  Cannot scroll up in diff mode with many filler lines and zero
          'scrolloff'.
Solution: Invalidate w_cline_row before calling comp_botline().

closes: #13256

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
src/move.c
src/testdir/test_diffmode.vim
src/version.c

index ba1eadb9ff79a6b2936ced773928ba99b66fae07..e5309df486a428d12c3d6f19ecab4f57c583f69e 100644 (file)
@@ -3262,6 +3262,7 @@ onepage(int dir, long count)
 #ifdef FEAT_DIFF
                        curwin->w_topfill = 0;
 #endif
+                       curwin->w_valid &= ~(VALID_WROW|VALID_CROW);
                    }
                    comp_botline(curwin);
                    curwin->w_cursor.lnum = curwin->w_botline - 1;
index cb042e115ad7797ef059d6ed6c6ffb58ffcd9750..e05d91601352ad39a1a74b4ade29813f47a91586 100644 (file)
@@ -1614,6 +1614,42 @@ func Test_diff_scroll_wrap_on()
   call assert_equal(1, winsaveview().topline)
   normal! j
   call assert_equal(2, winsaveview().topline)
+
+  bwipe!
+  bwipe!
+endfunc
+
+func Test_diff_scroll_many_filler()
+  20new
+  vnew
+  call setline(1, ['^^^', '^^^', '$$$', '$$$'])
+  diffthis
+  setlocal scrolloff=0
+  wincmd p
+  call setline(1, ['^^^', '^^^'] + repeat(['###'], 41) + ['$$$', '$$$'])
+  diffthis
+  setlocal scrolloff=0
+  wincmd p
+  redraw
+
+  " Note: need a redraw after each scroll, otherwise the test always passes.
+  normal! G
+  redraw
+  call assert_equal(3, winsaveview().topline)
+  call assert_equal(18, winsaveview().topfill)
+  exe "normal! \<C-B>"
+  redraw
+  call assert_equal(3, winsaveview().topline)
+  call assert_equal(19, winsaveview().topfill)
+  exe "normal! \<C-B>"
+  redraw
+  call assert_equal(2, winsaveview().topline)
+  call assert_equal(0, winsaveview().topfill)
+  exe "normal! \<C-B>"
+  redraw
+  call assert_equal(1, winsaveview().topline)
+  call assert_equal(0, winsaveview().topfill)
+
   bwipe!
   bwipe!
 endfunc
index d7b3c9bd331be8378a1e0ad9facfbf35e37a2fa7..15e87d62af2ea0e67735cf2322c8146b687d1b8a 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1981,
 /**/
     1980,
 /**/