patch 9.1.0380: Calculating line height for unnecessary amount of lines

Problem:  Calculating line height for unnecessary amount of lines with
          half-page scrolling (zhscn, after 9.1.0280)
Solution: Replace "limit_winheight" argument with higher resolution
          "max" argument to which to limit the calculated line height
          in plines_m_win() to (Luuk van Baal)

fixes: #14650
closes: #14652

Signed-off-by: Luuk van Baal <luukvbaal@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/misc1.c b/src/misc1.c
index c5a0c38..8348488 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -497,12 +497,17 @@
     return lines;
 }
 
+/*
+ * Return number of window lines the physical line range from "first" until
+ * "last" will occupy in window "wp". Takes into account folding, 'wrap',
+ * topfill and filler lines beyond the end of the buffer. Limit to "max" lines.
+ */
     int
-plines_m_win(win_T *wp, linenr_T first, linenr_T last, int limit_winheight)
+plines_m_win(win_T *wp, linenr_T first, linenr_T last, int max)
 {
     int		count = 0;
 
-    while (first <= last && (!limit_winheight || count < wp->w_height))
+    while (first <= last && count < max)
     {
 #ifdef FEAT_FOLDING
 	int	x;
@@ -531,9 +536,7 @@
     if (first == wp->w_buffer->b_ml.ml_line_count + 1)
 	count += diff_check_fill(wp, first);
 #endif
-    if (limit_winheight && count > wp->w_height)
-	return wp->w_height;
-    return (count);
+    return MIN(max, count);
 }
 
     int