Code

open_view: gather split view code in the same branch
authorJonas Fonseca <fonseca@diku.dk>
Fri, 11 Mar 2011 04:27:22 +0000 (23:27 -0500)
committerJonas Fonseca <fonseca@diku.dk>
Thu, 17 Mar 2011 01:21:01 +0000 (21:21 -0400)
tig.c

diff --git a/tig.c b/tig.c
index fd40b8e98027c3aeac5a9c55a130d902c98e102f..0f9394971629665bec78ae24e21fd6a3b83ffcf7 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -2722,7 +2722,6 @@ open_view(struct view *prev, enum request request, enum open_flags flags)
        bool reload = !!(flags & (OPEN_RELOAD | OPEN_PREPARED));
        struct view *view = VIEW(request);
        int nviews = displayed_views();
-       struct view *base_view = display[0];
 
        assert(flags ^ OPEN_REFRESH);
 
@@ -2740,11 +2739,27 @@ open_view(struct view *prev, enum request request, enum open_flags flags)
                display[1] = view;
                current_view = 1;
                view->parent = prev;
+               resize_display();
+
+               if (prev->lineno - prev->offset >= prev->height) {
+                       /* Take the title line into account. */
+                       int lines = prev->lineno - prev->offset - prev->height + 1;
+
+                       /* Scroll the view that was split if the current line is
+                        * outside the new limited view. */
+                       do_scroll_view(prev, lines);
+               }
+
+               if (view != prev && view_is_displayed(prev)) {
+                       /* "Blur" the previous view. */
+                       update_view_title(prev);
+               }
        } else {
                /* Maximize the current view. */
                memset(display, 0, sizeof(display));
                current_view = 0;
                display[current_view] = view;
+               resize_display();
        }
 
        /* No prev signals that this is the first loaded view. */
@@ -2752,26 +2767,6 @@ open_view(struct view *prev, enum request request, enum open_flags flags)
                view->prev = prev;
        }
 
-       /* Resize the view when switching between split- and full-screen,
-        * or when switching between two different full-screen views. */
-       if (nviews != displayed_views() ||
-           (nviews == 1 && base_view != display[0]))
-               resize_display();
-
-       if (split && prev->lineno - prev->offset >= prev->height) {
-               /* Take the title line into account. */
-               int lines = prev->lineno - prev->offset - prev->height + 1;
-
-               /* Scroll the view that was split if the current line is
-                * outside the new limited view. */
-               do_scroll_view(prev, lines);
-       }
-
-       if (prev && view != prev && split && view_is_displayed(prev)) {
-               /* "Blur" the previous view. */
-               update_view_title(prev);
-       }
-
        load_view(view, flags);
 }