Code

Refactor view loading from open_view into load_view
authorJonas Fonseca <fonseca@diku.dk>
Wed, 16 Mar 2011 01:28:46 +0000 (21:28 -0400)
committerJonas Fonseca <fonseca@diku.dk>
Thu, 17 Mar 2011 01:19:53 +0000 (21:19 -0400)
tig.c

diff --git a/tig.c b/tig.c
index 199eb34b7cfc434e915bf9026114dafb68ca280d..cc9b084dc1c2b1b15b10d7bbf8f5bcb22bafddc0 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -2690,6 +2690,29 @@ add_line_format(struct view *view, enum line_type type, const char *fmt, ...)
  * View opening
  */
 
+static void
+load_view(struct view *view, enum open_flags flags)
+{
+       if (view->pipe)
+               end_update(view, TRUE);
+       if (!view->ops->open(view, flags)) {
+               report("Failed to load %s view", view->name);
+               return;
+       }
+       restore_view_position(view);
+
+       if (view->pipe && view->lines == 0) {
+               /* Clear the old view and let the incremental updating refill
+                * the screen. */
+               werase(view->win);
+               view->p_restore = flags & (OPEN_RELOAD | OPEN_REFRESH);
+               report("");
+       } else if (view_is_displayed(view)) {
+               redraw_view(view);
+               report("");
+       }
+}
+
 static void
 open_view(struct view *prev, enum request request, enum open_flags flags)
 {
@@ -2732,16 +2755,6 @@ open_view(struct view *prev, enum request request, enum open_flags flags)
            (nviews == 1 && base_view != display[0]))
                resize_display();
 
-       if (view->ops->open) {
-               if (view->pipe)
-                       end_update(view, TRUE);
-               if (!view->ops->open(view, flags)) {
-                       report("Failed to load %s view", view->name);
-                       return;
-               }
-               restore_view_position(view);
-       }
-
        if (split && prev->lineno - prev->offset >= prev->height) {
                /* Take the title line into account. */
                int lines = prev->lineno - prev->offset - prev->height + 1;
@@ -2756,16 +2769,7 @@ open_view(struct view *prev, enum request request, enum open_flags flags)
                update_view_title(prev);
        }
 
-       if (view->pipe && view->lines == 0) {
-               /* Clear the old view and let the incremental updating refill
-                * the screen. */
-               werase(view->win);
-               view->p_restore = flags & (OPEN_RELOAD | OPEN_REFRESH);
-               report("");
-       } else if (view_is_displayed(view)) {
-               redraw_view(view);
-               report("");
-       }
+       load_view(view, flags);
 }
 
 static void