From 205fad57faea9d503eb6f61c31385ddfd32709fc Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 5 Oct 2026 13:46:55 +0200 Subject: [PATCH] Keep an emptied pane empty Emptying a pane of the main view clears it right away, but leaves the view's tasks alone. If a diff was asked for before, and its task is only created after the layout, that task fills the pane again. A diff's task that is still reading can also write into the emptied view. Give the pane an empty render as well. The render takes its place among the view's tasks, so the earlier diff's task isn't created, and it stops a task that is still reading. Once that task has stopped, the render empties the view again. Co-Authored-By: Claude Opus 5.5 (1M context) --- pkg/gui/main_panels.go | 13 +++++++++---- .../tests/main_view/keep_an_emptied_pane_empty.go | 3 --- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/gui/main_panels.go b/pkg/gui/main_panels.go index 5a723125b..abab6fcc8 100644 --- a/pkg/gui/main_panels.go +++ b/pkg/gui/main_panels.go @@ -355,9 +355,12 @@ func (gui *Gui) clampDiffSelectionToContent(view *gocui.View) { // claiming the render it was showing: whatever it is given next is content the user // hasn't seen there, and is shown from the top like any other. // -// A position waiting to be put back goes too: this pane is getting no render for it -// to ride, and whoever is waiting for the view to be back where it belongs has to -// hear that it never will be. +// The pane is emptied right away, and it is also given an empty render. The render +// takes its place among the view's tasks, so that a render asked for before it can't +// fill the pane again, whether that render's task is still to be created or is still +// reading. Like any render that isn't a re-render of what the pane was showing, it +// drops a position waiting to be put back: whoever is waiting for the view to be back +// where it belongs has to hear that it never will be. func (gui *Gui) clearMainView(mainContext types.Context) { view := mainContext.GetView() view.Clear() @@ -369,7 +372,9 @@ func (gui *Gui) clearMainView(mainContext types.Context) { gui.State.ContextMgr.UpdateSelectionHighlights() if manager := gui.getViewBufferManagerForView(view); manager != nil { manager.ForgetRenderedContent() - manager.DropRestoreForNextTask() + if err := gui.newStringTask(view, ""); err != nil { + gui.c.Log.Error(err) + } } } diff --git a/pkg/integration/tests/main_view/keep_an_emptied_pane_empty.go b/pkg/integration/tests/main_view/keep_an_emptied_pane_empty.go index 75e4800f2..a0b12509f 100644 --- a/pkg/integration/tests/main_view/keep_an_emptied_pane_empty.go +++ b/pkg/integration/tests/main_view/keep_an_emptied_pane_empty.go @@ -38,9 +38,6 @@ var KeepAnEmptiedPaneEmpty = NewIntegrationTest(NewIntegrationTestArgs{ t.Views().Secondary(). IsInvisible(). - /* EXPECTED: Content(Equals("")) - ACTUAL: */ - Content(Contains("+STAGED")) }, })