patch 9.0.0478: test for 'splitscroll' takes too much time
Problem: Test for 'splitscroll' takes too much time.
Solution: Only test some of the combinations. (Luuk van Baal, closes #11139)
diff --git a/src/window.c b/src/window.c
index fc7b8df..2e4a806 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6403,7 +6403,6 @@
static void
win_fix_cursor(int normal)
{
- int top = FALSE;
win_T *wp = curwin;
long so = get_scrolloff_value();
linenr_T nlnum = 0;
@@ -6418,7 +6417,7 @@
so = MIN(wp->w_height / 2, so);
// Check if cursor position is above topline or below botline.
if (wp->w_cursor.lnum < (wp->w_topline + so) && wp->w_topline != 1)
- top = nlnum = MIN(wp->w_topline + so, wp->w_buffer->b_ml.ml_line_count);
+ nlnum = MIN(wp->w_topline + so, wp->w_buffer->b_ml.ml_line_count);
else if (wp->w_cursor.lnum > (wp->w_botline - so - 1)
&& (wp->w_botline - wp->w_buffer->b_ml.ml_line_count) != 1)
nlnum = MAX(wp->w_botline - so - 1, 1);
@@ -6436,7 +6435,11 @@
}
else
{ // Ensure cursor stays visible if we are not in normal mode.
- wp->w_fraction = top ? 0 : FRACTION_MULT;
+ wp->w_fraction = 0.5 * FRACTION_MULT;
+ // Make sure cursor is closer to topline than botline.
+ if (so == wp->w_height / 2
+ && nlnum - wp->w_topline > wp->w_botline - 1 - nlnum)
+ wp->w_fraction++;
scroll_to_fraction(wp, wp->w_prev_height);
}
}