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) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-10-05 14:55:13 +02:00
co-authored by Claude Opus 5.5
parent f8fa6ee1a4
commit 205fad57fa
2 changed files with 9 additions and 7 deletions
+9 -4
View File
@@ -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)
}
}
}
@@ -38,9 +38,6 @@ var KeepAnEmptiedPaneEmpty = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Secondary().
IsInvisible().
/* EXPECTED:
Content(Equals(""))
ACTUAL: */
Content(Contains("+STAGED"))
},
})