diff --git a/pkg/gui/tasks_adapter.go b/pkg/gui/tasks_adapter.go index dd7999107..acad4fb75 100644 --- a/pkg/gui/tasks_adapter.go +++ b/pkg/gui/tasks_adapter.go @@ -118,7 +118,12 @@ func (gui *Gui) getManager(view *gocui.View) *tasks.ViewBufferManager { view.Reset() }, func() { - gui.render() + // As the task reads more lines, the only thing that changes is the + // view's content (and its scrollbar); the window layout doesn't. So a + // content-only render is enough, and it's much cheaper than a full + // layout-and-redraw on every read - which matters a lot when reading + // a long diff, where reads happen repeatedly as the user scrolls. + gui.renderContentOnly() }, func() { // Need to check if the content of the view is well past the origin. diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 453ccd6c9..d139984fa 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -121,6 +121,14 @@ func (gui *Gui) render() { gui.c.OnUIThread(func() error { return nil }) } +// renderContentOnly triggers a re-render that skips the layout pass and only +// redraws the views whose content changed (relying on tcell's cell-level dirty +// tracking to emit just the cells that actually differ). Use it when only a +// view's content changed, not the window layout. +func (gui *Gui) renderContentOnly() { + gui.c.OnUIThreadContentOnly(func() error { return nil }) +} + // postRefreshUpdate is to be called on a context after the state that it depends on has been refreshed // if the context's view is set to another context we do nothing. // if the context's view is the current view we trigger a focus; re-selecting the current item.