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

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
tog: reset blame view's scroll position
To:
gameoftrees@openbsd.org
Date:
Sun, 13 Dec 2020 17:42:05 +0100

Download raw body.

Thread
This CHANGES entry...

- tog: reset diff view's scroll position if diff context shrinks too much

... reminded me that we have a similar issue in the blame view.

* tog blame -r got.git tog/tog.c
* move to the very last line
* hit 'b'
* congratulations, you are now on line 6493 of 203, and have a whole
  lot of moving up to do before you encounter your first line of code
  across this vast desert of emptiness

How about this?

diff b2d2e70d74ef419da60fefbc2a7c5900c181e2e7 /home/naddy/got
blob - 99232045ade1a4d37286e512dd4999368a1b89b5
file + tog/tog.c
--- tog/tog.c
+++ tog/tog.c
@@ -4254,6 +4254,12 @@ run_blame(struct tog_view *view)
 	blame->thread_args.cancel_arg = &s->done;
 	s->blame_complete = 0;
 
+	if (s->first_displayed_line + view->nlines - 1 > blame->nlines) {
+		s->first_displayed_line = 1;
+		s->last_displayed_line = view->nlines;
+		s->selected_line = 1;
+	}
+
 done:
 	if (blob)
 		got_object_blob_close(blob);
-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de