commit - 89a34d6e53b40dde314248e45b8f3b626fbf85c6
commit + 364ac6fd6d8e9ecf616ce569d655cbc3ad8f7680
blob - a3b1cc5362b33b8201b17b28e35e4f005f9f9cd9
blob + 9cd42f902d4f41a14a433d2050208c035a7a0993
--- tog/tog.c
+++ tog/tog.c
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;
}