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

From:
Mark Jamsek <mark@jamsek.com>
Subject:
tog: fix delayed tree index update
To:
Game of Trees <gameoftrees@openbsd.org>
Date:
Fri, 12 Aug 2022 21:49:31 +1000

Download raw body.

Thread
Nice simple fix :)

Use the first displayed entry and line index to update the tree index so
we don't have a delay after halfdelay has been set via the blame view.

repro:
  $ tog tree
  return  # open blame view
  tab  # cycle back to tree view
  10g
  *it takes 1 second for the index to change from 1/19 to 10/19*

ok?

-----------------------------------------------
commit b0ba1586c82f5ca67a961d57d81f57ba6aac119a (fix/treeidx)
from: Mark Jamsek <mark@jamsek.dev>
date: Fri Aug 12 11:38:34 2022 UTC
 
 tog: fix delayed tree index update
 
 If a child blame view has been opened, halfdelay() is reset to a 1 second
 refresh rate, so the index in the header lags behind subtree navigation as we
 set the index based on the selected tree entry, which isn't updated till that
 refresh cycle completes. Don't wait for the selected_entry to update; instead,
 compute the index from the first displayed entry and the currently selected
 line index.
 
diff d30ab56fff40b038af410d963b66e866a8e4e528 b0ba1586c82f5ca67a961d57d81f57ba6aac119a
commit - d30ab56fff40b038af410d963b66e866a8e4e528
commit + b0ba1586c82f5ca67a961d57d81f57ba6aac119a
blob - 79bd77c80f7773fd9a6bd7e5f5cfeb69ff90f91c
blob + 91e344fe64d3c78e3af58761cebf690382525711
--- tog/tog.c
+++ tog/tog.c
@@ -6375,9 +6375,10 @@ draw_tree_entries(struct tog_view *view, const char *p
 	free(wline);
 	wline = NULL;
 
-	if (s->selected_entry) {
-		i = got_tree_entry_get_index(s->selected_entry);
-		i += s->tree == s->root ? 1 : 2;  /* account for ".." entry */
+	i += s->selected;
+	if (s->first_displayed_entry) {
+		i += got_tree_entry_get_index(s->first_displayed_entry);
+		i += s->tree != s->root;  /* account for ".." entry */
 	}
 	nentries = got_object_tree_get_nentries(s->tree);
 	wprintw(view->window, " [%d/%d]", i,


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