"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Mikhail Pchelin <misha@freebsd.org>
Subject:
[PATCH] add vim-style search wrapped message
To:
gameoftrees@openbsd.org
Date:
Fri, 24 Jul 2026 10:05:19 +0300

Download raw body.

Thread
[please keep me cc'ed]

This patch adds messages about search wrap, helps if you scroll large
diff and got past the last search entry.

Worth a review?

diff refs/heads/main 6096532e41131f081514620dbf6dbf194f55c22a
commit - b3611acb7c736d2f45369e1eea2806450e9d11b2
commit + 6096532e41131f081514620dbf6dbf194f55c22a
blob - fa1d997063a644a4ac763e75014f65aff610f0f3
blob + 8c1700d2e9ff8dcf5ea8b755db2aedbc5d2dfe2c
--- tog/tog.c
+++ tog/tog.c
@@ -766,6 +766,10 @@ struct tog_view {
 #define TOG_SEARCH_HAVE_MORE	1
 #define TOG_SEARCH_NO_MORE	2
 #define TOG_SEARCH_HAVE_NONE	3
+#define TOG_MSG_SEARCH_WRAP_FORWARD \
+	"search hit BOTTOM, continuing at TOP"
+#define TOG_MSG_SEARCH_WRAP_BACKWARD \
+	"search hit TOP, continuing at BOTTOM"
 	regex_t regex;
 	regmatch_t regmatch;
 	const char *action;
@@ -6759,10 +6763,13 @@ search_next_view_match(struct tog_view *view)
 				break;
 			}
 
-			if (view->searching == TOG_SEARCH_FORWARD)
+			if (view->searching == TOG_SEARCH_FORWARD) {
 				lineno = 1;
-			else
+				view->action = TOG_MSG_SEARCH_WRAP_FORWARD;
+			} else {
 				lineno = nlines;
+				view->action = TOG_MSG_SEARCH_WRAP_BACKWARD;
+			}
 		}
 
 		offset = view->type == TOG_VIEW_DIFF ?
@@ -9505,10 +9512,13 @@ search_next_tree_view(struct tog_view *view)
 				view->search_next_done = TOG_SEARCH_HAVE_MORE;
 				return NULL;
 			}
-			if (view->searching == TOG_SEARCH_FORWARD)
+			if (view->searching == TOG_SEARCH_FORWARD) {
 				te = got_object_tree_get_first_entry(s->tree);
-			else
+				view->action = TOG_MSG_SEARCH_WRAP_FORWARD;
+			} else {
 				te = got_object_tree_get_last_entry(s->tree);
+				view->action = TOG_MSG_SEARCH_WRAP_BACKWARD;
+			}
 
 			if (te == NULL)
 				break;
@@ -10229,10 +10239,13 @@ search_next_ref_view(struct tog_view *view)
 				view->search_next_done = TOG_SEARCH_HAVE_MORE;
 				return NULL;
 			}
-			if (view->searching == TOG_SEARCH_FORWARD)
+			if (view->searching == TOG_SEARCH_FORWARD) {
 				re = TAILQ_FIRST(&s->refs);
-			else
+				view->action = TOG_MSG_SEARCH_WRAP_FORWARD;
+			} else {
 				re = TAILQ_LAST(&s->refs, tog_reflist_head);
+				view->action = TOG_MSG_SEARCH_WRAP_BACKWARD;
+			}
 		}
 
 		if (match_reflist_entry(re, &view->regex)) {