From ebfa8c71b2274e75766b671ab39d5050768228a0 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 9 Aug 2026 08:15:36 +0200 Subject: [PATCH] Drop FlushStaleCells, which no longer has anything to flush It existed for the incremental re-render: a shorter render left the previous one's view lines in the tail (deliberately, to avoid a blank frame), and this cleared them once the new content was fully read. Async renders now build off-screen and swap in whole, so refreshViewLinesIfNeeded truncates the view lines to the buffer and no tail can form. All the call at end-of-input still did was discard every wrapped line and force the whole buffer to be re-wrapped on the next draw, which is pure work on a large diff. Co-Authored-By: Claude Opus 5 (1M context) --- pkg/commands/oscommands/pty_windows.go | 3 ++- pkg/gocui/view.go | 11 ----------- pkg/gui/tasks_adapter.go | 2 -- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/pkg/commands/oscommands/pty_windows.go b/pkg/commands/oscommands/pty_windows.go index e645ae627..ff707c519 100644 --- a/pkg/commands/oscommands/pty_windows.go +++ b/pkg/commands/oscommands/pty_windows.go @@ -204,7 +204,8 @@ func (p *winPty) Close() error { // slave closes on child exit, but ConPTY keeps the pipe alive until we call // ClosePseudoConsole explicitly. Without doing that on child exit, the // scanner in pkg/tasks.NewCmdTask would block forever on the next read and -// the post-content view never gets cleared (FlushStaleCells never fires). +// the render would never reach its end of input, so the new content would +// never be swapped in. func startWaiter(proc *os.Process, p *winPty) func() error { done := make(chan struct{}) var waitErr error diff --git a/pkg/gocui/view.go b/pkg/gocui/view.go index fe01e50ca..dba71ab52 100644 --- a/pkg/gocui/view.go +++ b/pkg/gocui/view.go @@ -1248,17 +1248,6 @@ func (v *View) Reset() { v.offscreen = nil } -// This is for when we've done a restart for the sake of avoiding a flicker and -// we've reached the end of the new content to display: we need to clear the remaining -// content from the previous round. We do this by setting v.viewLines to nil so that -// we just render the new content from v.buf.lines directly -func (v *View) FlushStaleCells() { - v.writeMutex.Lock() - defer v.writeMutex.Unlock() - - v.clearViewLines() -} - // BeginOffscreenRender starts building a re-render into an off-screen buffer. // Until SwapInOffscreenRender promotes it, writes go to that buffer and the // displayed buffer — what every reader sees — is left as it was. This is how an diff --git a/pkg/gui/tasks_adapter.go b/pkg/gui/tasks_adapter.go index f2f567a75..5e5295639 100644 --- a/pkg/gui/tasks_adapter.go +++ b/pkg/gui/tasks_adapter.go @@ -170,8 +170,6 @@ func (gui *Gui) getManager(view *gocui.View) *tasks.ViewBufferManager { view.SetOrigin(0, newOriginY) } - - view.FlushStaleCells() }, func() { view.SetOrigin(0, 0)