patch 9.1.0294: Text height function does not respect it's argument

Problem:  plines_m_win() does not take into account it's "limit_winheight"
          argument for filler lines below the last line of the buffer.
          (after v9.1.0280)
Solution: Check window height when "limit_winheight" is TRUE.
          (Luuk van Baal)

closes: #14449

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 7ee4712..c5a0c38 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -502,7 +502,7 @@
 {
     int		count = 0;
 
-    while (first <= last)
+    while (first <= last && (!limit_winheight || count < wp->w_height))
     {
 #ifdef FEAT_FOLDING
 	int	x;
@@ -519,17 +519,20 @@
 #endif
 	{
 #ifdef FEAT_DIFF
-	    if (first == wp->w_buffer->b_ml.ml_line_count)
-		count += diff_check_fill(wp, first + 1);
 	    if (first == wp->w_topline)
-		count += plines_win_nofill(wp, first, limit_winheight)
-							       + wp->w_topfill;
+		count += plines_win_nofill(wp, first, FALSE) + wp->w_topfill;
 	    else
 #endif
-		count += plines_win(wp, first, limit_winheight);
+		count += plines_win(wp, first, FALSE);
 	    ++first;
 	}
     }
+#ifdef FEAT_DIFF
+    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);
 }
 
diff --git a/src/move.c b/src/move.c
index 9853b0b..8c6fbd6 100644
--- a/src/move.c
+++ b/src/move.c
@@ -3210,7 +3210,7 @@
 	{
 	    int n = plines_correct_topline(curwin, curwin->w_topline, FALSE);
 	    if (n - count < curwin->w_height && curwin->w_topline < buflen)
-		n += plines_m_win(curwin, curwin->w_topline + 1, buflen, TRUE);
+		n += plines_m_win(curwin, curwin->w_topline + 1, buflen, FALSE);
 	    if (n - count < curwin->w_height)
 		count = n - curwin->w_height;
 	}
diff --git a/src/popupwin.c b/src/popupwin.c
index bdf4ac7..25bb153 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -654,7 +654,7 @@
 	    wp->w_topline = wp->w_buffer->b_ml.ml_line_count;
 	while (wp->w_topline < wp->w_cursor.lnum
 		&& wp->w_topline < wp->w_buffer->b_ml.ml_line_count
-		&& plines_m_win(wp, wp->w_topline, wp->w_cursor.lnum, TRUE)
+		&& plines_m_win(wp, wp->w_topline, wp->w_cursor.lnum, FALSE)
 								> wp->w_height)
 	    ++wp->w_topline;
     }
diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim
index f28e840..098d5d0 100644
--- a/src/testdir/test_diffmode.vim
+++ b/src/testdir/test_diffmode.vim
Binary files differ
diff --git a/src/version.c b/src/version.c
index 70f1425..f39d30a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    294,
+/**/
     293,
 /**/
     292,