summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7672417)
raw | patch | inline | side by side (parent: 7672417)
author | Jonas Fonseca <fonseca@diku.dk> | |
Thu, 27 Mar 2008 10:47:00 +0000 (11:47 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Thu, 27 Mar 2008 19:45:22 +0000 (20:45 +0100) |
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.
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 | patch | blob | history |
index dc48eed4ebac1a882dd9d26d39944e5ed6603bd7..25a77ff04a730ca7ede52609b3bbf0b6ac66ea06 100644 (file)
--- a/tig.c
+++ b/tig.c
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)
(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;
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)
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;
}