Hi Bram and list,

How to reproduce:
- Ran vanilla Vim.
  $ vim --clean
- Prepare test data on Vim
  :call setline(1, range(1,19))
- Fold around the last line.
  9GzfG
- Do page down by type CTRL-F.
  <C-F>
- The following information is displayed on the folded part of the first line. 
  +-- 11 lines: 9---------         <---- Expected.
- Do page down again.
  <C-F>
- The following information is displayed on the folded part of the first line. 
  +--  1 line: 19---------         <---- Unexpected!!! Should be `+-- 11 lines: 
9---------`
- Do page up, page down and page down.
  <C-B><C-F><C-F>
- Confirm that folding information is not displayed on the first line.
                                   <---- Unexpected!!! Should be `+-- 11 lines: 
9---------`


Note:
This issue also happens when in diff mode.  (Current buffer only)

I wrote a patch contains test.
Please check it.
--
Best regards,
Hirohito Higashi (h_east)

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/move.c b/src/move.c
index a56003013..b2b84868a 100644
--- a/src/move.c
+++ b/src/move.c
@@ -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);
diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim
index de6688365..df4b12c8c 100644
--- a/src/testdir/test_fold.vim
+++ b/src/testdir/test_fold.vim
@@ -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

Raspunde prin e-mail lui