Skip to content

Commit 9adbef4

Browse files
committed
Refresh staging panel when committing
We now refresh the staging panel when doing an unscoped refresh, so that if we commit from the staging panel we escape back to the files panel if need be. But that causes flickering when doing an unscoped refresh from other contexts, because the refreshStagingPanel function assumes that the staging panel has focus. So we're adding a guard at the top of that function to early exit if we don't have focus.
1 parent 0cd5257 commit 9adbef4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/gui/refresh.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func (gui *Gui) Refresh(options types.RefreshOptions) error {
8585
types.REMOTES,
8686
types.STATUS,
8787
types.BISECT_INFO,
88+
types.STAGING,
8889
})
8990
} else {
9091
scopeSet = set.NewFromSlice(options.Scope)
@@ -563,6 +564,13 @@ func (gui *Gui) refreshStatus() {
563564

564565
func (gui *Gui) refreshStagingPanel(focusOpts types.OnFocusOpts) error {
565566
secondaryFocused := gui.secondaryStagingFocused()
567+
mainFocused := gui.mainStagingFocused()
568+
569+
// this method could be called when the staging panel is not being used,
570+
// in which case we don't want to do anything.
571+
if !mainFocused && !secondaryFocused {
572+
return nil
573+
}
566574

567575
mainSelectedLineIdx := -1
568576
secondarySelectedLineIdx := -1
@@ -647,6 +655,10 @@ func (gui *Gui) secondaryStagingFocused() bool {
647655
return gui.currentStaticContext().GetKey() == gui.State.Contexts.StagingSecondary.GetKey()
648656
}
649657

658+
func (gui *Gui) mainStagingFocused() bool {
659+
return gui.currentStaticContext().GetKey() == gui.State.Contexts.Staging.GetKey()
660+
}
661+
650662
func (gui *Gui) refreshPatchBuildingPanel(opts types.OnFocusOpts) error {
651663
selectedLineIdx := -1
652664
if opts.ClickedWindowName == "main" {

0 commit comments

Comments
 (0)