summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-01-18 20:43:08 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-01-18 21:25:52 +1100
commitb6fb7f13657435a789b39eabfc4414d2ec203588 (patch)
treee06a99517ba4eb032503d55033e88236fad10efe
parentdbb8b17d839cea811238f2575474f97176bc90a1 (diff)
fix integration test
-rw-r--r--pkg/gui/context_config.go8
-rw-r--r--pkg/gui/diff_context_size.go17
-rw-r--r--pkg/gui/patch_building_panel.go11
-rw-r--r--pkg/gui/staging_panel.go11
4 files changed, 41 insertions, 6 deletions
diff --git a/pkg/gui/context_config.go b/pkg/gui/context_config.go
index 9e12a1896..2b587a62e 100644
--- a/pkg/gui/context_config.go
+++ b/pkg/gui/context_config.go
@@ -136,7 +136,7 @@ func (gui *Gui) contextTree() ContextTree {
Key: MAIN_NORMAL_CONTEXT_KEY,
},
Staging: &BasicContext{
- OnRenderToMain: func(opts ...OnFocusOpts) error {
+ OnFocus: func(opts ...OnFocusOpts) error {
forceSecondaryFocused := false
selectedLineIdx := -1
if len(opts) > 0 && opts[0].ClickedViewName != "" {
@@ -147,20 +147,20 @@ func (gui *Gui) contextTree() ContextTree {
forceSecondaryFocused = true
}
}
- return gui.handleRefreshStagingPanel(forceSecondaryFocused, selectedLineIdx)
+ return gui.onStagingFocus(forceSecondaryFocused, selectedLineIdx)
},
Kind: MAIN_CONTEXT,
ViewName: "main",
Key: MAIN_STAGING_CONTEXT_KEY,
},
PatchBuilding: &BasicContext{
- OnRenderToMain: func(opts ...OnFocusOpts) error {
+ OnFocus: func(opts ...OnFocusOpts) error {
selectedLineIdx := -1
if len(opts) > 0 && (opts[0].ClickedViewName == "main" || opts[0].ClickedViewName == "secondary") {
selectedLineIdx = opts[0].ClickedViewLineIdx
}
- return gui.handleRefreshPatchBuildingPanel(selectedLineIdx)
+ return gui.onPatchBuildingFocus(selectedLineIdx)
},
Kind: MAIN_CONTEXT,
ViewName: "main",
diff --git a/pkg/gui/diff_context_size.go b/pkg/gui/diff_context_size.go
index ff7786c8a..3b6f6b0a9 100644
--- a/pkg/gui/diff_context_size.go
+++ b/pkg/gui/diff_context_size.go
@@ -32,7 +32,7 @@ func (gui *Gui) IncreaseContextInDiffView() error {
}
gui.UserConfig.Git.DiffContextSize = gui.UserConfig.Git.DiffContextSize + 1
- return gui.currentStaticContext().HandleRenderToMain()
+ return gui.handleDiffContextSizeChange()
}
return nil
@@ -47,12 +47,25 @@ func (gui *Gui) DecreaseContextInDiffView() error {
}
gui.UserConfig.Git.DiffContextSize = old_size - 1
- return gui.currentStaticContext().HandleRenderToMain()
+ return gui.handleDiffContextSizeChange()
}
return nil
}
+func (gui *Gui) handleDiffContextSizeChange() error {
+ currentContext := gui.currentStaticContext()
+ switch currentContext.GetKey() {
+ // we make an exception for our staging and patch building contexts because they actually need to refresh their state afterwards.
+ case MAIN_PATCH_BUILDING_CONTEXT_KEY:
+ return gui.handleRefreshPatchBuildingPanel(-1)
+ case MAIN_STAGING_CONTEXT_KEY:
+ return gui.handleRefreshStagingPanel(false, -1)
+ default:
+ return currentContext.HandleRenderToMain()
+ }
+}
+
func (gui *Gui) CheckCanChangeContext() error {
if gui.Git.Patch.PatchManager.Active() {
return errors.New(gui.Tr.CantChangeContextSizeError)
diff --git a/pkg/gui/patch_building_panel.go b/pkg/gui/patch_building_panel.go
index ee1610fb4..bf0c95fa1 100644
--- a/pkg/gui/patch_building_panel.go
+++ b/pkg/gui/patch_building_panel.go
@@ -62,6 +62,17 @@ func (gui *Gui) handleRefreshPatchBuildingPanel(selectedLineIdx int) error {
return gui.refreshPatchBuildingPanel(selectedLineIdx)
}
+func (gui *Gui) onPatchBuildingFocus(selectedLineIdx int) error {
+ gui.Mutexes.LineByLinePanelMutex.Lock()
+ defer gui.Mutexes.LineByLinePanelMutex.Unlock()
+
+ if gui.State.Panels.LineByLine == nil || selectedLineIdx != -1 {
+ return gui.refreshPatchBuildingPanel(selectedLineIdx)
+ }
+
+ return nil
+}
+
func (gui *Gui) handleToggleSelectionForPatch() error {
err := gui.withLBLActiveCheck(func(state *LblPanelState) error {
toggleFunc := gui.Git.Patch.PatchManager.AddFileLineRange
diff --git a/pkg/gui/staging_panel.go b/pkg/gui/staging_panel.go
index f4409d76c..ecb208dcc 100644
--- a/pkg/gui/staging_panel.go
+++ b/pkg/gui/staging_panel.go
@@ -74,6 +74,17 @@ func (gui *Gui) handleRefreshStagingPanel(forceSecondaryFocused bool, selectedLi
return gui.refreshStagingPanel(forceSecondaryFocused, selectedLineIdx)
}
+func (gui *Gui) onStagingFocus(forceSecondaryFocused bool, selectedLineIdx int) error {
+ gui.Mutexes.LineByLinePanelMutex.Lock()
+ defer gui.Mutexes.LineByLinePanelMutex.Unlock()
+
+ if gui.State.Panels.LineByLine == nil || selectedLineIdx != -1 {
+ return gui.refreshStagingPanel(forceSecondaryFocused, selectedLineIdx)
+ }
+
+ return nil
+}
+
func (gui *Gui) handleTogglePanel() error {
return gui.withLBLActiveCheck(func(state *LblPanelState) error {
state.SecondaryFocused = !state.SecondaryFocused