From: Stefan Sperling Subject: Re: tog log search vs selected commit To: Tracey Emery Cc: Christian Weisgerber , gameoftrees@openbsd.org Date: Thu, 9 Dec 2021 19:21:51 +0100 On Thu, Dec 09, 2021 at 07:35:06AM -0700, Tracey Emery wrote: > On Thu, Dec 09, 2021 at 02:31:42PM +0100, Christian Weisgerber wrote: > > Stefan Sperling: > > > > > At present tog always begins searching from the youngest commit. > > > > > > With the patch below we always start searching from the currently > > > selected commit. Is this better? Does this break things for anyone? > > > > I'm all for it. > > Same! I've wanted the functionality for some time, but never looked at > it. I constantly use the 'n' 'N' search functions in nvim/tmux/etc. Thanks, the patch has been committed. This is the equivalent change for all the other views. ok? diff 4a55b231883da25896fe302c04b11284bad0e125 /home/stsp/src/got blob - 771539241603427427680ffdc1db88ad3456d10a file + tog/tog.c --- tog/tog.c +++ tog/tog.c @@ -3428,12 +3428,8 @@ search_next_diff_view(struct tog_view *view) lineno = s->matched_line + 1; else lineno = s->matched_line - 1; - } else { - if (view->searching == TOG_SEARCH_FORWARD) - lineno = 1; - else - lineno = s->nlines; - } + } else + lineno = s->first_displayed_line; while (1) { off_t offset; @@ -4478,12 +4474,8 @@ search_next_blame_view(struct tog_view *view) lineno = s->matched_line + 1; else lineno = s->matched_line - 1; - } else { - if (view->searching == TOG_SEARCH_FORWARD) - lineno = 1; - else - lineno = s->blame.nlines; - } + } else + lineno = s->first_displayed_line - 1 + s->selected_line; while (1) { off_t offset; @@ -5368,7 +5360,9 @@ search_next_tree_view(struct tog_view *view) s->selected_entry); } } else { - if (view->searching == TOG_SEARCH_FORWARD) + if (s->selected_entry) + te = s->selected_entry; + else if (view->searching == TOG_SEARCH_FORWARD) te = got_object_tree_get_first_entry(s->tree); else te = got_object_tree_get_last_entry(s->tree); @@ -6027,7 +6021,9 @@ search_next_ref_view(struct tog_view *view) tog_reflist_head, entry); } } else { - if (view->searching == TOG_SEARCH_FORWARD) + if (s->selected_entry) + re = s->selected_entry; + else if (view->searching == TOG_SEARCH_FORWARD) re = TAILQ_FIRST(&s->refs); else re = TAILQ_LAST(&s->refs, tog_reflist_head);