patch 9.1.1062: terminal: E315 when dragging the terminal with the mouse

Problem:  terminal: E315 when dragging the terminal with the mouse
          (user202729)
Solution: call update_topline() and validate_cursor() when clicking
          on the status line with the mouse (Hirohito Higashi)

fixes: #16024
fixes: #16211
closes: #16552

Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/mouse.c b/src/mouse.c
index 4e10e72..3bdb102 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -1902,6 +1902,16 @@
 	    // Drag the status line
 	    count = row - W_WINROW(dragwin) - dragwin->w_height + 1
 							     - on_status_line;
+#ifdef FEAT_TERMINAL
+	    if (bt_terminal(dragwin->w_buffer))
+	    {
+		win_T *curwin_save = curwin;
+		curwin = dragwin;
+		update_topline();
+		validate_cursor();
+		curwin = curwin_save;
+	    }
+#endif
 	    win_drag_status_line(dragwin, count);
 	    did_drag |= count;
 	}