summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-23 11:08:51 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-23 14:29:18 +1000
commita95fd581fde17651151e4fb0b34494447e07c959 (patch)
tree89b1b75e219012fce825c7e6790a19f4bc061a29 /pkg/gui
parentfda9f4ea7a476a11d4a50cbbd9ce657fe69ae2cb (diff)
fix logic for entering merging panel
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/context.go24
-rw-r--r--pkg/gui/files_panel.go1
2 files changed, 12 insertions, 13 deletions
diff --git a/pkg/gui/context.go b/pkg/gui/context.go
index 945f815e8..7b74d94a3 100644
--- a/pkg/gui/context.go
+++ b/pkg/gui/context.go
@@ -249,9 +249,7 @@ func (gui *Gui) contextTree() ContextTree {
Merging: SimpleContextNode{
Context: BasicContext{
OnFocus: func() error {
- return nil
- // TODO: centralise the code here
- // return gui.refreshMergePanel()
+ return gui.refreshMergePanel()
},
Kind: MAIN_CONTEXT,
ViewName: "main",
@@ -448,13 +446,7 @@ func (gui *Gui) activateContext(c Context) error {
if err != nil {
return gui.returnFromContext()
}
-
- // if the new context's view was previously displaying another context, render the new context
- if v.Context != c.GetKey() {
- if err := c.HandleRender(); err != nil {
- return err
- }
- }
+ originalViewContextKey := v.Context
// ensure that any other window for which this view was active is now set to the default for that window.
gui.setViewAsActiveForWindow(viewName)
@@ -475,10 +467,16 @@ func (gui *Gui) activateContext(c Context) error {
return err
}
- newView := gui.g.CurrentView()
- newView.Context = c.GetKey()
+ // if the new context's view was previously displaying another context, render the new context
+ if originalViewContextKey != c.GetKey() {
+ if err := c.HandleRender(); err != nil {
+ return err
+ }
+ }
+
+ v.Context = c.GetKey()
- gui.g.Cursor = newView.Editable
+ gui.g.Cursor = v.Editable
// render the options available for the current context at the bottom of the screen
optionsMap := c.GetOptionsMap()
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index 61f3815fb..488b7f569 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -572,6 +572,7 @@ func (gui *Gui) handleSwitchToMerge() error {
if !file.HasInlineMergeConflicts {
return gui.createErrorPanel(gui.Tr.SLocalize("FileNoMergeCons"))
}
+
return gui.switchContext(gui.Contexts.Merging.Context)
}