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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: tog: fix resize failure to populate log view commits
To:
Mark Jamsek <mark@jamsek.com>
Cc:
gameoftrees@openbsd.org
Date:
Mon, 18 Jul 2022 15:18:46 +0200

Download raw body.

Thread
On Mon, Jul 18, 2022 at 11:12:27PM +1000, Mark Jamsek wrote:
> On 22-07-18 02:49pm, Stefan Sperling wrote:
> > On Mon, Jul 18, 2022 at 10:34:27PM +1000, Mark Jamsek wrote:
> > > If resizing a log view while on the _last_ loaded commit on the bottom
> > > edge of the screen, some of the new lines are not populated.
> > > 
> > > repro:
> > > $ tog  # 80x24
> > > 23j  # move down to the last commit
> > > *increase terminal height to ~30 lines then reduce back to 80x24*
> > > ~5j  # move down to the _last_ commit
> > > *increase terminal height to ~33 lines*
> > > 
> > > Most of the new lines are empty.
> > > 
> > > We call request_log_commits() from view_resize()--but only when the view
> > > has a child view. The fix simply moves this check, so that we always
> > > call request_log_commits() if the terminal height has been increased,
> > > irrespective of whether a child view exists.
> > 
> > I only have a concern about style consistency:
> > 
> > Could we add a resize function pointer to struct tog_view and call this
> > (if not NULL) instead of checking the view type and manipulating diff
> > view state in view_resize() directly?
> > 
> > The code would then move into a new resize_diff_view() function.
> 
> Sure! That would be better. Do you mean just the logic for requesting
> commits in the event the terminal height is increased into
> a resize_log_view() routine to be called from view_resize()?

Look at how reset_diff_view and reset_blame_view work.
Any view-specific resizing code could be called in the same way.

You would probably end up with something like this in view_resize();

	if (view->resize) {
		err = view->resize(view, dif);
		if (err)
			return err;
	}