patch 8.0.1797: terminal window is redrawn too often

Problem:    Terminal window is redrawn too often and scrolling is repeated.
Solution:   Don't scroll immediately but only when redrawing.  Avoid redrawing
            the whole terminal window on every change.
diff --git a/src/screen.c b/src/screen.c
index 06dc304..cff6ae5 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -567,8 +567,12 @@
 	must_redraw = 0;
     }
 
-    /* Need to update w_lines[]. */
-    if (curwin->w_lines_valid == 0 && type < NOT_VALID)
+    /* May need to update w_lines[]. */
+    if (curwin->w_lines_valid == 0 && type < NOT_VALID
+#ifdef FEAT_TERMINAL
+	    && !term_do_update_window(curwin)
+#endif
+		)
 	type = NOT_VALID;
 
     /* Postpone the redrawing when it's not needed and when being called
@@ -1172,10 +1176,10 @@
     }
 
 #ifdef FEAT_TERMINAL
-    /* If this window contains a terminal, redraw works completely differently.
-     */
-    if (term_update_window(wp) == OK)
+    // If this window contains a terminal, redraw works completely differently.
+    if (term_do_update_window(wp))
     {
+	term_update_window(wp);
 # ifdef FEAT_MENU
 	/* Draw the window toolbar, if there is one. */
 	if (winbar_height(wp) > 0)