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

From:
Mikhail <mp39590@gmail.com>
Subject:
tog {diff,blame}: respect current first line as a start line for next search
To:
gameoftrees@openbsd.org
Date:
Sat, 1 Apr 2023 16:09:18 +0300

Download raw body.

Thread
Inlined patch makes tog {diff,blame} respect current first line while
searching next match, here is illustration: imagine {diff,blame} view
contains following lines matching or not matching search expression:

1 notmatch
2 notmatch
3 match
4 match

When initiating the search tog will jump to line 3, making it first line
on the screen:

3 match
4 match
~
~

now if you scroll one line back:

2 notmatch
3 match
4 match
~

and hit 'n' tog won't respect current first line and will jump you to
line 4. The patch makes it jump to line 3 again.

It is consistent with 'tog log' view, where we respect current cursor
position for the next search, also less/vim behave this way.

diff /home/misha/work/got
commit - e9e0377f452e9d3f600011e0714cc6c779f10bab
path + /home/misha/work/got
blob - 40201c25f18ee7225e330e73140e4238037d66e3
file + tog/tog.c
--- tog/tog.c
+++ tog/tog.c
@@ -4977,9 +4977,9 @@ search_next_view_match(struct tog_view *view)
 
 	if (*match) {
 		if (view->searching == TOG_SEARCH_FORWARD)
-			lineno = *match + 1;
+			lineno = *first + 1;
 		else
-			lineno = *match - 1;
+			lineno = *first - 1;
 	} else
 		lineno = *first - 1 + *selected;