commit f9967bca13c359aa4ba51c67a63fad42f9569626 from: Stefan Sperling date: Fri Mar 27 09:21:24 2020 UTC display "no matches found" if no commit matches a 'tog log' search commit - 8f4ed63441b6c8e9c29c4db32ad615a1657aa1ac commit + f9967bca13c359aa4ba51c67a63fad42f9569626 blob - e4a29913017c957f0d4f8e06cdd86094f3999c58 blob + 627443ff42c81342f3b1dd935e34b99a36b0a211 --- tog/tog.c +++ tog/tog.c @@ -439,6 +439,7 @@ struct tog_view { int search_next_done; #define TOG_SEARCH_HAVE_MORE 1 #define TOG_SEARCH_NO_MORE 2 +#define TOG_SEARCH_HAVE_NONE 3 regex_t regex; }; @@ -754,8 +755,9 @@ view_input(struct tog_view **new, struct tog_view **de *dead = NULL; *focus = NULL; - /* Clear "no more matches" indicator. */ - if (view->search_next_done == TOG_SEARCH_NO_MORE) + /* Clear "no matches" indicator. */ + if (view->search_next_done == TOG_SEARCH_NO_MORE || + view->search_next_done == TOG_SEARCH_HAVE_NONE) view->search_next_done = TOG_SEARCH_HAVE_MORE; if (view->searching && !view->search_next_done) { @@ -1518,7 +1520,9 @@ draw_commits(struct tog_view *view, struct commit_queu if (asprintf(&ncommits_str, " [%d/%d] %s", entry ? entry->idx + 1 : 0, commits->ncommits, view->search_next_done == TOG_SEARCH_NO_MORE ? - "no more matches" : (refs_str ? refs_str : "")) == -1) { + "no more matches" : + (view->search_next_done == TOG_SEARCH_HAVE_NONE ? + "no matches found" : (refs_str ? refs_str : ""))) == -1) { err = got_error_from_errno("asprintf"); goto done; } @@ -2095,7 +2099,9 @@ search_next_log_view(struct tog_view *view) if (entry == NULL) { if (s->thread_args.log_complete || view->searching == TOG_SEARCH_BACKWARD) { - view->search_next_done = TOG_SEARCH_NO_MORE; + view->search_next_done = + (s->matched_entry == NULL ? + TOG_SEARCH_HAVE_NONE : TOG_SEARCH_NO_MORE); s->search_entry = NULL; return NULL; }