Code

Refactor find_next_line into select_view_line
authorJonas Fonseca <fonseca@diku.dk>
Sun, 18 Jan 2009 01:58:47 +0000 (02:58 +0100)
committerJonas Fonseca <fonseca@diku.dk>
Thu, 22 Jan 2009 10:11:19 +0000 (11:11 +0100)
tig.c

diff --git a/tig.c b/tig.c
index 32d2fb7d8a143a06883cc29523575ac9f99a5f7a..24794c6c32bb06d58abcbc750c89e1878127ec71 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -2406,14 +2406,11 @@ move_view(struct view *view, enum request request)
 
 static void search_view(struct view *view, enum request request);
 
-static bool
-find_next_line(struct view *view, unsigned long lineno, struct line *line)
+static void
+select_view_line(struct view *view, unsigned long lineno)
 {
        assert(view_is_displayed(view));
 
-       if (!view->ops->grep(view, line))
-               return FALSE;
-
        if (lineno - view->offset >= view->height) {
                view->offset = lineno;
                view->lineno = lineno;
@@ -2429,9 +2426,6 @@ find_next_line(struct view *view, unsigned long lineno, struct line *line)
                redrawwin(view->win);
                wrefresh(view->win);
        }
-
-       report("Line %ld matches '%s'", lineno + 1, view->grep);
-       return TRUE;
 }
 
 static void
@@ -2469,10 +2463,11 @@ find_next(struct view *view, enum request request)
        /* Note, lineno is unsigned long so will wrap around in which case it
         * will become bigger than view->lines. */
        for (; lineno < view->lines; lineno += direction) {
-               struct line *line = &view->line[lineno];
-
-               if (find_next_line(view, lineno, line))
+               if (view->ops->grep(view, &view->line[lineno])) {
+                       select_view_line(view, lineno);
+                       report("Line %ld matches '%s'", lineno + 1, view->grep);
                        return;
+               }
        }
 
        report("No match found for '%s'", view->grep);