From 318628193256a71ffe9a7a9f595ad1c8e74b239f Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Thu, 27 Mar 2008 11:47:00 +0100 Subject: [PATCH] Fix and improve status refreshing after updating Update the view offset so the current line is already visible. This requires that the display is split or initialized before starting to load the view so status_open has the view->height available. --- tig.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/tig.c b/tig.c index dc48eed..25a77ff 100644 --- a/tig.c +++ b/tig.c @@ -2278,18 +2278,6 @@ open_view(struct view *prev, enum request request, enum open_flags flags) return; } - if (view->ops->open) { - if (!view->ops->open(view)) { - report("Failed to load %s view", view->name); - return; - } - - } else if ((reload || strcmp(view->vid, view->id)) && - !begin_update(view)) { - report("Failed to load %s view", view->name); - return; - } - if (split) { display[1] = view; if (!backgrounded) @@ -2307,6 +2295,18 @@ 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->ops->open(view)) { + report("Failed to load %s view", view->name); + return; + } + + } else if ((reload || strcmp(view->vid, view->id)) && + !begin_update(view)) { + report("Failed to load %s view", view->name); + return; + } + if (split && prev->lineno - prev->offset >= prev->height) { /* Take the title line into account. */ int lines = prev->lineno - prev->offset - prev->height + 1; @@ -3964,6 +3964,8 @@ status_open(struct view *view) prev_lineno = view->lines - 1; while (prev_lineno < view->lines && !view->line[prev_lineno].data) prev_lineno++; + while (prev_lineno > 0 && !view->line[prev_lineno].data) + prev_lineno--; /* If the above fails, always skip the "On branch" line. */ if (prev_lineno < view->lines) @@ -3971,6 +3973,11 @@ status_open(struct view *view) else view->lineno = 1; + if (view->lineno < view->offset) + view->offset = view->lineno; + else if (view->offset + view->height <= view->lineno) + view->offset = view->lineno - view->height + 1; + return TRUE; } -- 2.30.2