@@ -2457,22 +2457,27 @@ onepage(int dir, long count)
24572457 beginline (BL_SOL | BL_FIX );
24582458 curwin -> w_valid &= ~(VALID_WCOL |VALID_WROW |VALID_VIRTCOL );
24592459
2460- /*
2461- * Avoid the screen jumping up and down when 'scrolloff' is non-zero.
2462- * But make sure we scroll at least one line (happens with mix of long
2463- * wrapping lines and non-wrapping line).
2464- */
2465- if (retval == OK && dir == FORWARD && check_top_offset ())
2460+ if (retval == OK && dir == FORWARD )
24662461 {
2467- scroll_cursor_top (1 , FALSE);
2468- if (curwin -> w_topline <= old_topline
2469- && old_topline < curbuf -> b_ml .ml_line_count )
2462+ // Avoid the screen jumping up and down when 'scrolloff' is non-zero.
2463+ // But make sure we scroll at least one line (happens with mix of long
2464+ // wrapping lines and non-wrapping line).
2465+ if (check_top_offset ())
24702466 {
2471- curwin -> w_topline = old_topline + 1 ;
2467+ scroll_cursor_top (1 , FALSE);
2468+ if (curwin -> w_topline <= old_topline
2469+ && old_topline < curbuf -> b_ml .ml_line_count )
2470+ {
2471+ curwin -> w_topline = old_topline + 1 ;
24722472#ifdef FEAT_FOLDING
2473- (void )hasFolding (curwin -> w_topline , & curwin -> w_topline , NULL );
2473+ (void )hasFolding (curwin -> w_topline , & curwin -> w_topline , NULL );
24742474#endif
2475+ }
24752476 }
2477+ #ifdef FEAT_FOLDING
2478+ else if (curwin -> w_botline > curbuf -> b_ml .ml_line_count )
2479+ (void )hasFolding (curwin - > w_topline , & curwin - > w_topline , NULL );
2480+ #endif
24762481 }
24772482
24782483 redraw_later (VALID );
0 commit comments