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

From:
Mark Jamsek <mark@jamsek.com>
Subject:
Re: tog {diff,blame}: respect current first line as a start line for next search
To:
Omar Polo <op@omarpolo.com>
Cc:
Mikhail <mp39590@gmail.com>, gameoftrees@openbsd.org
Date:
Sun, 2 Apr 2023 11:52:16 +1000

Download raw body.

Thread
On 23-04-01 05:21PM, Omar Polo wrote:
> 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

Yes, I agree. It makes sense for these views as the first displayed line
is the cursor or current line.

I have committed this. 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;
> >  
> 
> 

-- 
Mark Jamsek <fnc.bsdbox.org|got.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68