Download raw body.
tog {diff,blame}: respect current first line as a start line for next search
tog {diff,blame}: respect current first line as a start line for next search
On 2023/04/01 16:09:18 +0300, Mikhail <mp39590@gmail.com> wrote:
> 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.
fwiw I prefer your suggestion to the current behaviour; having n going
to the first match starting from the current "cursor position" (the
topmost line.)
the diff also reads fine to me
Thanks!
> 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;
>
tog {diff,blame}: respect current first line as a start line for next search
tog {diff,blame}: respect current first line as a start line for next search