summaryrefslogtreecommitdiffstats
path: root/pkg/gui/controllers/helpers
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-04-29 13:41:29 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-04-30 13:19:54 +1000
commitaf97bf484cd8eaba64b7fd4a10aed36d1f5f0690 (patch)
treed4c23c879dd430f00f92012903a0655c5e789d4b /pkg/gui/controllers/helpers
parenta57310df240405770d37f46362b28fe464ef9531 (diff)
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.
Diffstat (limited to 'pkg/gui/controllers/helpers')
-rw-r--r--pkg/gui/controllers/helpers/refresh_helper.go1
-rw-r--r--pkg/gui/controllers/helpers/staging_helper.go11
2 files changed, 12 insertions, 0 deletions
diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go
index 2c3bc4c91..354a2115b 100644
--- a/pkg/gui/controllers/helpers/refresh_helper.go
+++ b/pkg/gui/controllers/helpers/refresh_helper.go
@@ -80,6 +80,7 @@ func (self *RefreshHelper) Refresh(options types.RefreshOptions) error {
types.REMOTES,
types.STATUS,
types.BISECT_INFO,
+ types.STAGING,
})
} else {
scopeSet = set.NewFromSlice(options.Scope)
diff --git a/pkg/gui/controllers/helpers/staging_helper.go b/pkg/gui/controllers/helpers/staging_helper.go
index da67de9b8..75280b985 100644
--- a/pkg/gui/controllers/helpers/staging_helper.go
+++ b/pkg/gui/controllers/helpers/staging_helper.go
@@ -21,6 +21,13 @@ func NewStagingHelper(
// NOTE: used from outside this file
func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) error {
secondaryFocused := self.secondaryStagingFocused()
+ mainFocused := self.mainStagingFocused()
+
+ // this method could be called when the staging panel is not being used,
+ // in which case we don't want to do anything.
+ if !mainFocused && !secondaryFocused {
+ return nil
+ }
mainSelectedLineIdx := -1
secondarySelectedLineIdx := -1
@@ -109,3 +116,7 @@ func (self *StagingHelper) handleStagingEscape() error {
func (self *StagingHelper) secondaryStagingFocused() bool {
return self.c.CurrentStaticContext().GetKey() == self.c.Contexts().StagingSecondary.GetKey()
}
+
+func (self *StagingHelper) mainStagingFocused() bool {
+ return self.c.CurrentStaticContext().GetKey() == self.c.Contexts().Staging.GetKey()
+}