From: Stefan Sperling Subject: tog log search vs selected commit To: gameoftrees@openbsd.org Date: Wed, 8 Dec 2021 15:08:42 +0100 At present tog always begins searching from the youngest commit. This is not ideal when browsing a long history all the way to the bottom and then starting a search from there. The cursor jumps all the way up again and we may have to traverse countless matches before reaching a commit near the bottom where we were looking for something. With the patch below we always start searching from the currently selected commit. Is this better? Does this break things for anyone? By the way, I sometimes find myself trying to start a backwards-search with the '?' key but this is not implemented. All searches begin as forward-searches right now. The 'N' key will continue a search in progress and go backwards. But there is no way to start out searching backwards. Should we add this feature? It would only make sense on top of the patch below. Otherwise, a '?' search would start out at the youngest commit and try to search upwards in history, where there are no commits to search. diff 2c1e11283575d6f3c2b10bb265695f1dbddc79e0 f3d7a5740a1396ac5b98fd8da66e935615c62b17 blob - 67c8c724634dc19b2e580668d89aaed73820aade blob + 771539241603427427680ffdc1db88ad3456d10a --- tog/tog.c +++ tog/tog.c @@ -2191,10 +2191,7 @@ search_next_log_view(struct tog_view *view) entry = TAILQ_PREV(s->matched_entry, commit_queue_head, entry); } else { - if (view->searching == TOG_SEARCH_FORWARD) - entry = TAILQ_FIRST(&s->commits.head); - else - entry = TAILQ_LAST(&s->commits.head, commit_queue_head); + entry = s->selected_entry; } while (1) {