Code

Fix status_exists to be consistent with data displayed in the stage view
authorJonas Fonseca <fonseca@diku.dk>
Thu, 22 Jan 2009 16:00:45 +0000 (17:00 +0100)
committerJonas Fonseca <fonseca@diku.dk>
Thu, 22 Jan 2009 16:06:13 +0000 (17:06 +0100)
tig.c

diff --git a/tig.c b/tig.c
index 0e1028a7d709ffda3200e85b63c2d583785ebb5e..238033278f7bc89d3e40401ef02889d9fb4d3d6d 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -4568,17 +4568,22 @@ static bool
 status_exists(struct status *status, enum line_type type)
 {
        struct view *view = VIEW(REQ_VIEW_STATUS);
-       struct line *line;
+       unsigned long lineno;
 
-       for (line = view->line; line < view->line + view->lines; line++) {
+       for (lineno = 0; lineno < view->lines; lineno++) {
+               struct line *line = &view->line[lineno];
                struct status *pos = line->data;
 
                if (line->type != type)
                        continue;
-               if (!pos && (!status || !status->status))
+               if (!pos && (!status || !status->status) && line[1].data) {
+                       select_view_line(view, lineno);
                        return TRUE;
-               if (pos && !strcmp(status->new.name, pos->new.name))
+               }
+               if (pos && !strcmp(status->new.name, pos->new.name)) {
+                       select_view_line(view, lineno);
                        return TRUE;
+               }
        }
 
        return FALSE;