Re-render focused main view on refresh if needed

This commit is contained in:
Stefan Haller 2025-03-26 14:39:44 +01:00
parent 98e4cb733f
commit 4e21a096b9

View file

@ -4,6 +4,7 @@ import (
"time"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/tasks"
"github.com/jesseduffield/lazygit/pkg/utils"
@ -143,5 +144,17 @@ func (gui *Gui) postRefreshUpdate(c types.Context) {
// correctly, and that integration tests see the up to date selection
// state.
c.FocusLine()
currentCtx := gui.State.ContextMgr.Current()
if currentCtx.GetKey() == context.NORMAL_MAIN_CONTEXT_KEY || currentCtx.GetKey() == context.NORMAL_SECONDARY_CONTEXT_KEY {
// Searching can't cope well with the view being updated while it is being searched.
// We might be able to fix the problems with this, but it doesn't seem easy, so for now
// just don't rerender the view while searching, on the assumption that users will probably
// either search or change their data, but not both at the same time.
if !currentCtx.GetView().IsSearching() {
parentCtx := currentCtx.GetParentContext()
parentCtx.HandleRenderToMain()
}
}
}
}