Only resize the display when actually required
[tig] / tig.c
diff --git a/tig.c b/tig.c
index bf53092..4ab9434 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -1075,11 +1075,27 @@ move_view(struct view *view, enum request request, bool redraw)
  * Incremental updating
  */
 
+static void
+end_update(struct view *view)
+{
+       if (!view->pipe)
+               return;
+       set_nonblocking_input(FALSE);
+       if (view->pipe == stdin)
+               fclose(view->pipe);
+       else
+               pclose(view->pipe);
+       view->pipe = NULL;
+}
+
 static bool
 begin_update(struct view *view)
 {
        const char *id = view->id;
 
+       if (view->pipe)
+               end_update(view);
+
        if (opt_cmd[0]) {
                string_copy(view->cmd, opt_cmd);
                opt_cmd[0] = 0;
@@ -1128,19 +1144,6 @@ begin_update(struct view *view)
        return TRUE;
 }
 
-static void
-end_update(struct view *view)
-{
-       if (!view->pipe)
-               return;
-       set_nonblocking_input(FALSE);
-       if (view->pipe == stdin)
-               fclose(view->pipe);
-       else
-               pclose(view->pipe);
-       view->pipe = NULL;
-}
-
 static bool
 update_view(struct view *view)
 {
@@ -1282,7 +1285,8 @@ open_view(struct view *prev, enum request request, enum open_flags flags)
                display[current_view] = view;
        }
 
-       resize_display();
+       if (nviews == 1 || display[1] == NULL)
+               resize_display();
 
        if (split && prev->lineno - prev->offset >= prev->height) {
                /* Take the title line into account. */
@@ -1294,13 +1298,13 @@ open_view(struct view *prev, enum request request, enum open_flags flags)
        }
 
        if (prev && view != prev) {
-               /* "Blur" the previous view. */
-               if (!backgrounded)
-                       update_view_title(prev);
-
                /* Continue loading split views in the background. */
                if (!split)
                        end_update(prev);
+               else if (!backgrounded)
+                       /* "Blur" the previous view. */
+                       update_view_title(prev);
+
                view->parent = prev;
        }
 
@@ -1364,11 +1368,12 @@ view_driver(struct view *view, enum request request)
 
                if (view == VIEW(REQ_VIEW_DIFF) &&
                    view->parent == VIEW(REQ_VIEW_MAIN)) {
-                       bool redraw = display[0] == VIEW(REQ_VIEW_MAIN);
+                       bool redraw = display[1] == view;
 
                        view = view->parent;
                        move_view(view, request, redraw);
-                       update_view_title(view);
+                       if (redraw)
+                               update_view_title(view);
                } else {
                        move_view(view, request, TRUE);
                        break;