diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-04-29 13:41:29 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-04-30 13:19:54 +1000 |
commit | af97bf484cd8eaba64b7fd4a10aed36d1f5f0690 (patch) | |
tree | d4c23c879dd430f00f92012903a0655c5e789d4b /pkg/gui/controllers/helpers/staging_helper.go | |
parent | a57310df240405770d37f46362b28fe464ef9531 (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/staging_helper.go')
-rw-r--r-- | pkg/gui/controllers/helpers/staging_helper.go | 11 |
1 files changed, 11 insertions, 0 deletions
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() +} |