Download raw body.
search issues in tog after cursor movement
While studying tog code, I found that search behaves a little bit
strange if you move cursor after you hit the match.
To illustrate this open tog in got repository and search for 'foo'
(there are 3 matches), after you hit the last one, hit Home and then
'n', it will say 'no more matches'.
I think it's not what is expected by a user, at least mutt and editors
don't behave that way.
Can you assess the following patch?
diff refs/heads/main refs/heads/search
blob - 8782d2289745425a1fdaecbd1edbcab6c230e7e6
blob + a23ffa80af77e01eae15224e4b699b0e6e8a3020
--- tog/tog.c
+++ tog/tog.c
@@ -2342,11 +2342,25 @@ search_next_log_view(struct tog_view *view)
entry = TAILQ_PREV(s->search_entry,
commit_queue_head, entry);
} else if (s->matched_entry) {
+ int matched_idx = s->matched_entry->idx;
+ int selected_idx = s->selected_entry->idx;
+
+ /*
+ * If user has moved cursor after we hit the match, position
+ * from where we should continue search must be changed.
+ */
if (view->searching == TOG_SEARCH_FORWARD)
- entry = TAILQ_NEXT(s->matched_entry, entry);
+ if (matched_idx > selected_idx)
+ entry = TAILQ_NEXT(s->selected_entry, entry);
+ else
+ entry = TAILQ_NEXT(s->matched_entry, entry);
else
- entry = TAILQ_PREV(s->matched_entry,
- commit_queue_head, entry);
+ if (matched_idx < selected_idx)
+ entry = TAILQ_PREV(s->selected_entry,
+ commit_queue_head, entry);
+ else
+ entry = TAILQ_PREV(s->matched_entry,
+ commit_queue_head, entry);
} else {
entry = s->selected_entry;
}
search issues in tog after cursor movement