From: Stefan Sperling Subject: Re: tog: clear search highlighting when reloading view To: Christian Weisgerber Cc: gameoftrees@openbsd.org Date: Fri, 24 Dec 2021 12:20:25 +0100 On Thu, Dec 23, 2021 at 09:07:48PM +0100, Christian Weisgerber wrote: > Stefan Sperling: > > > > @@ -3793,6 +3793,7 @@ input_diff_view(struct tog_view **new_view, struct tog > > > > > > s->first_displayed_line = 1; > > > s->last_displayed_line = view->nlines; > > > + s->matched_line = 0; > > > > > > diff_view_indicate_progress(view); > > > err = create_diff(s); > > > > There is a case which you missed for the diff view: Changing the amount > > of diff context with '[' or ']' has the same problem. > > As do 'a' and 'w', presumably. Indeed! > > Instead of having at least three places which reset those 3 variables, > > maybe create a function that resets diff view state and call it from > > at least those three places? > > Well, ']' doesn't reset the other two variables and '[' only does > so conditionally. > > All affected commands call diff_view_indicate_progress() and > create_diff(), but semantically, "s->matched_line = 0" doesn't feel > like it belongs to either. Fair enough. I won't insist on using a new function. What is more important is that tog's behaviour gets fixed somehow. We can still decide to do some code refactoring later.