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

From:
Mark Jamsek <mark@jamsek.com>
Subject:
tog: populate new child log lines when switching split
To:
gameoftrees@openbsd.org
Date:
Thu, 21 Jul 2022 00:15:43 +1000

Download raw body.

Thread
I just noticed this now while using the new blame -> log key map that
opens a child log view. If you first open the log view with 'L' in
a hsplit and then switch to a vsplit, the new log lines are empty (repro
recipe below).

The new resize_log_view() method stsp suggested comes in handy here as
it does all the math for us and calls request_log_commits() if needed
when log view lines are increased, so the fix is to just check for and
call view->resize rather than trying to determine when we need to
request n more commits.

The below diff fixes this case, but I also want to go through and
replace all the appropriate

if (view->type == TOG_VIEW_LOG)
	request_log_commits(view);

bits with this view->resize idiom; it's a lot cleaner and, as stsp
remarked, more consistent style-wise too.  I don't have the time to do
this tonight so want to push this fix out and do the rest later.

-----------------------------------------------
commit b1cabdf3e6c4ae8f321b764cb0fcc30453f89b3c (fix/logvsplit)
from: Mark Jamsek <mark@jamsek.dev>
date: Wed Jul 20 14:07:31 2022 UTC

 tog: populate new child view log lines when switching split

 When switching a newly opened child log view from a h- to a v-split, the
 new log lines are empty:
   $ tog blame CHANGES
   S  # toggle hsplit
   L  # open log view
   S  # switch to vsplit
   *new log lines are empty*

 When switching splits, call the recently added resize_log_view() method to do
 the work and populate new lines if needed.

diff 05f04cdf3fa9619d7055f098b55f1633dbbf12c0 b1cabdf3e6c4ae8f321b764cb0fcc30453f89b3c
commit - 05f04cdf3fa9619d7055f098b55f1633dbbf12c0
commit + b1cabdf3e6c4ae8f321b764cb0fcc30453f89b3c
blob - f05786c2a00509ae1a6a3159214d55188847d9c9
blob + 785c10661752b8c4217bb0c44fe460a884cf8d98
--- tog/tog.c
+++ tog/tog.c
@@ -1210,10 +1210,10 @@ switch_split(struct tog_view *view)
 		offset_selection_up(v);
 		offset_selection_up(v->child);
 	}
-	if (v->type == TOG_VIEW_LOG && v->nscrolled)
-		err = request_log_commits(v);
-	else if (v->child->type == TOG_VIEW_LOG && v->child->nscrolled)
-		err = request_log_commits(v->child);
+	if (v->resize)
+		err = v->resize(v, 0);
+	else if (v->child->resize)
+		err = v->child->resize(v->child, 0);

 	return err;
 }


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