aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/move.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/move.c')
-rw-r--r--src/nvim/move.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c
index eb55397511..b129c5cb7a 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -1010,12 +1010,9 @@ scrollup (
int byfold /* true: count a closed fold as one line */
)
{
- if (
- (byfold && hasAnyFolding(curwin))
- ||
- curwin->w_p_diff
- ) {
- /* count each sequence of folded lines as one logical line */
+ if ((byfold && hasAnyFolding(curwin))
+ || curwin->w_p_diff) {
+ // count each sequence of folded lines as one logical line
linenr_T lnum = curwin->w_topline;
while (line_count--) {
if (curwin->w_topfill > 0)
@@ -1288,9 +1285,10 @@ void scroll_cursor_top(int min_scroll, int always)
* - at least 'scrolloff' lines above and below the cursor
*/
validate_cheight();
- int used = curwin->w_cline_height;
- if (curwin->w_cursor.lnum < curwin->w_topline)
+ int used = curwin->w_cline_height; // includes filler lines above
+ if (curwin->w_cursor.lnum < curwin->w_topline) {
scrolled = used;
+ }
if (hasFolding(curwin->w_cursor.lnum, &top, &bot)) {
--top;
@@ -1301,9 +1299,10 @@ void scroll_cursor_top(int min_scroll, int always)
}
new_topline = top + 1;
- /* count filler lines of the cursor window as context */
+ // "used" already contains the number of filler lines above, don't add it
+ // again.
+ // Hide filler lines above cursor line by adding them to "extra".
int extra = diff_check_fill(curwin, curwin->w_cursor.lnum);
- used += extra;
/*
* Check if the lines from "top" to "bot" fit in the window. If they do,
@@ -1312,7 +1311,7 @@ void scroll_cursor_top(int min_scroll, int always)
while (top > 0) {
int i = hasFolding(top, &top, NULL)
? 1 // count one logical line for a sequence of folded lines
- : plines(top);
+ : plines_nofill(top);
used += i;
if (extra + i <= off && bot < curbuf->b_ml.ml_line_count) {
if (hasFolding(bot, NULL, &bot))