Code

Make it possible to call select_view_line for non-displayed views
authorJonas Fonseca <fonseca@diku.dk>
Thu, 22 Jan 2009 15:59:00 +0000 (16:59 +0100)
committerJonas Fonseca <fonseca@diku.dk>
Thu, 22 Jan 2009 15:59:00 +0000 (16:59 +0100)
tig.c

diff --git a/tig.c b/tig.c
index 24794c6c32bb06d58abcbc750c89e1878127ec71..0e1028a7d709ffda3200e85b63c2d583785ebb5e 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -2409,22 +2409,24 @@ static void search_view(struct view *view, enum request request);
 static void
 select_view_line(struct view *view, unsigned long lineno)
 {
-       assert(view_is_displayed(view));
-
        if (lineno - view->offset >= view->height) {
                view->offset = lineno;
                view->lineno = lineno;
-               redraw_view(view);
+               if (view_is_displayed(view))
+                       redraw_view(view);
 
        } else {
                unsigned long old_lineno = view->lineno - view->offset;
 
                view->lineno = lineno;
-               draw_view_line(view, old_lineno);
-
-               draw_view_line(view, view->lineno - view->offset);
-               redrawwin(view->win);
-               wrefresh(view->win);
+               if (view_is_displayed(view)) {
+                       draw_view_line(view, old_lineno);
+                       draw_view_line(view, view->lineno - view->offset);
+                       redrawwin(view->win);
+                       wrefresh(view->win);
+               } else {
+                       view->ops->select(view, &view->line[view->lineno]);
+               }
        }
 }