]> granicus.if.org Git - vim/commitdiff
patch 8.1.0174: after paging up and down fold line is wrong v8.1.0174
authorBram Moolenaar <Bram@vim.org>
Tue, 10 Jul 2018 13:07:15 +0000 (15:07 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 10 Jul 2018 13:07:15 +0000 (15:07 +0200)
Problem:    After paging up and down fold line is wrong.
Solution:   Correct the computation of w_topline and w_botline. (Hirohito
            Higashi)

src/move.c
src/testdir/test_fold.vim
src/version.c

index a56003013c68009742b04c320a42b23b84cea7b0..b2b84868acfc77fbd45b47a27264f400ddc38c15 100644 (file)
@@ -2457,22 +2457,27 @@ onepage(int dir, long count)
        beginline(BL_SOL | BL_FIX);
     curwin->w_valid &= ~(VALID_WCOL|VALID_WROW|VALID_VIRTCOL);
 
-    /*
-     * Avoid the screen jumping up and down when 'scrolloff' is non-zero.
-     * But make sure we scroll at least one line (happens with mix of long
-     * wrapping lines and non-wrapping line).
-     */
-    if (retval == OK && dir == FORWARD && check_top_offset())
+    if (retval == OK && dir == FORWARD)
     {
-       scroll_cursor_top(1, FALSE);
-       if (curwin->w_topline <= old_topline
-                                 && old_topline < curbuf->b_ml.ml_line_count)
+       // Avoid the screen jumping up and down when 'scrolloff' is non-zero.
+       // But make sure we scroll at least one line (happens with mix of long
+       // wrapping lines and non-wrapping line).
+       if (check_top_offset())
        {
-           curwin->w_topline = old_topline + 1;
+           scroll_cursor_top(1, FALSE);
+           if (curwin->w_topline <= old_topline
+                                 && old_topline < curbuf->b_ml.ml_line_count)
+           {
+               curwin->w_topline = old_topline + 1;
 #ifdef FEAT_FOLDING
-           (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
+               (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
 #endif
+           }
        }
+#ifdef FEAT_FOLDING
+       else if (curwin->w_botline > curbuf->b_ml.ml_line_count)
+           (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
+#endif
     }
 
     redraw_later(VALID);
index de6688365d933aea255243e18571ce0634381aa2..df4b12c8ceba2a363b6665c1ac8624d421976b5e 100644 (file)
@@ -1,5 +1,7 @@
 " Test for folding
 
+source view_util.vim
+
 func PrepIndent(arg)
   return [a:arg] + repeat(["\t".a:arg], 5)
 endfu
@@ -648,3 +650,27 @@ func Test_foldopen_exception()
   endtry
   call assert_match('E492:', a)
 endfunc
+
+func Test_fold_last_line_with_pagedown()
+  enew!
+  set fdm=manual
+
+  let expect = '+-- 11 lines: 9---'
+  let content = range(1,19)
+  call append(0, content)
+  normal dd9G
+  normal zfG
+  normal zt
+  call assert_equal('9', getline(foldclosed('.')))
+  call assert_equal('19', getline(foldclosedend('.')))
+  call assert_equal(expect, ScreenLines(1, len(expect))[0])
+  call feedkeys("\<C-F>", 'xt')
+  call assert_equal(expect, ScreenLines(1, len(expect))[0])
+  call feedkeys("\<C-F>", 'xt')
+  call assert_equal(expect, ScreenLines(1, len(expect))[0])
+  call feedkeys("\<C-B>\<C-F>\<C-F>", 'xt')
+  call assert_equal(expect, ScreenLines(1, len(expect))[0])
+
+  set fdm&
+  enew!
+endfunc
index de6f550dd6ed80fa953e364be4c4888993d7e6d7..6b422e6703bb2ee8a0cde17e26839baa7a4f3acf 100644 (file)
@@ -789,6 +789,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    174,
 /**/
     173,
 /**/