commit - 0f4feb58a3a8349d878d406fbd88a9774df62ddb
commit + df5e841d09305f99fc2b172349b1caf24bf1e10b
blob - 744279af4125b89c0e241b674e3f246a81abd037
blob + 6bb3d20611de9bd51888a5832be3b5d253fe08d5
--- 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;
}