Code

Make Enter in the pager view always scroll
authorJonas Fonseca <fonseca@diku.dk>
Sat, 20 May 2006 13:22:28 +0000 (15:22 +0200)
committerJonas Fonseca <fonseca@antimatter.localdomain>
Sat, 20 May 2006 13:22:28 +0000 (15:22 +0200)
It will still split to diff view if a commit line is detected.

tig.c

diff --git a/tig.c b/tig.c
index 3b78ef754ed9b0718194867d534eb4cede92f7c3..7e5f9ae1d5f7cd125de8f232892bcb35715b6ebb 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -1564,18 +1564,25 @@ static bool
 pager_enter(struct view *view)
 {
        char *line = view->line[view->lineno];
+       int split = 0;
 
-       if (view == VIEW(REQ_VIEW_DIFF)) {
-               scroll_view(view, REQ_SCROLL_LINE_DOWN);
-               return TRUE;
+       if ((view == VIEW(REQ_VIEW_LOG) ||
+            view == VIEW(REQ_VIEW_LOG)) &&
+           get_line_type(line) == LINE_COMMIT) {
+               open_view(view, REQ_VIEW_DIFF, OPEN_SPLIT);
+               split = 1;
        }
 
-       if (get_line_type(line) == LINE_COMMIT) {
-               if (view == VIEW(REQ_VIEW_LOG))
-                       open_view(view, REQ_VIEW_DIFF, OPEN_SPLIT | OPEN_BACKGROUNDED);
-               else
-                       open_view(view, REQ_VIEW_DIFF, OPEN_DEFAULT);
-       }
+       /* Always scroll the view even if it was split. That way
+        * you can use Enter to scroll through the log view and
+        * split open each commit diff. */
+       scroll_view(view, REQ_SCROLL_LINE_DOWN);
+
+       /* FIXME: A minor workaround. Scrolling the view will call report("")
+        * but if we are scolling a non-current view this won't properly update
+        * the view title. */
+       if (split)
+               update_view_title(view);
 
        return TRUE;
 }