Commit 67b5eae12158038ee5cb00b808702891527cd70e

Christian Weisgerber 2021-12-27T19:01:57

tog: clear search highlighting when reloading view Clear the search highlighting when replacing the content of a diff view ('<', '>', '[', ']', 'a', 'w') or a blame view ('b', 'p', 'B'). Previously the position would remain highlighted even if the text there had changed. ok stsp@ or a blame view

diff --git a/tog/tog.c b/tog/tog.c
index 689aa4b..4416f59 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -3699,6 +3699,7 @@ input_diff_view(struct tog_view **new_view, struct tog_view *view, int ch)
 		wclear(view->window);
 		s->first_displayed_line = 1;
 		s->last_displayed_line = view->nlines;
+		s->matched_line = 0;
 		diff_view_indicate_progress(view);
 		err = create_diff(s);
 		break;
@@ -3757,6 +3758,7 @@ input_diff_view(struct tog_view **new_view, struct tog_view *view, int ch)
 	case '[':
 		if (s->diff_context > 0) {
 			s->diff_context--;
+			s->matched_line = 0;
 			diff_view_indicate_progress(view);
 			err = create_diff(s);
 			if (s->first_displayed_line + view->nlines - 1 >
@@ -3769,6 +3771,7 @@ input_diff_view(struct tog_view **new_view, struct tog_view *view, int ch)
 	case ']':
 		if (s->diff_context < GOT_DIFF_MAX_CONTEXT) {
 			s->diff_context++;
+			s->matched_line = 0;
 			diff_view_indicate_progress(view);
 			err = create_diff(s);
 		}
@@ -3793,6 +3796,7 @@ input_diff_view(struct tog_view **new_view, struct tog_view *view, int ch)
 
 		s->first_displayed_line = 1;
 		s->last_displayed_line = view->nlines;
+		s->matched_line = 0;
 
 		diff_view_indicate_progress(view);
 		err = create_diff(s);
@@ -3817,6 +3821,7 @@ input_diff_view(struct tog_view **new_view, struct tog_view *view, int ch)
 
 		s->first_displayed_line = 1;
 		s->last_displayed_line = view->nlines;
+		s->matched_line = 0;
 
 		diff_view_indicate_progress(view);
 		err = create_diff(s);
@@ -4369,6 +4374,7 @@ run_blame(struct tog_view *view)
 		s->last_displayed_line = view->nlines;
 		s->selected_line = 1;
 	}
+	s->matched_line = 0;
 
 done:
 	if (blob)