File tree Expand file tree Collapse file tree 7 files changed +29
-11
lines changed Expand file tree Collapse file tree 7 files changed +29
-11
lines changed Original file line number Diff line number Diff line change @@ -357,3 +357,19 @@ func (self *ContextMgr) CurrentPopup() []types.Context {
357
357
return context .GetKind () == types .TEMPORARY_POPUP || context .GetKind () == types .PERSISTENT_POPUP
358
358
})
359
359
}
360
+
361
+ func (self * ContextMgr ) NextInStack (c types.Context ) types.Context {
362
+ self .RLock ()
363
+ defer self .RUnlock ()
364
+
365
+ for i := range self .ContextStack {
366
+ if self .ContextStack [i ].GetKey () == c .GetKey () {
367
+ if i == 0 {
368
+ return nil
369
+ }
370
+ return self .ContextStack [i - 1 ]
371
+ }
372
+ }
373
+
374
+ panic ("context not in stack" )
375
+ }
Original file line number Diff line number Diff line change @@ -131,7 +131,9 @@ func (self *ContextLinesController) currentSidePanel() types.Context {
131
131
currentContext := self .c .Context ().CurrentStatic ()
132
132
if currentContext .GetKey () == context .NORMAL_MAIN_CONTEXT_KEY ||
133
133
currentContext .GetKey () == context .NORMAL_SECONDARY_CONTEXT_KEY {
134
- return currentContext .GetParentContext ()
134
+ if sidePanelContext := self .c .Context ().NextInStack (currentContext ); sidePanelContext != nil {
135
+ return sidePanelContext
136
+ }
135
137
}
136
138
137
139
return currentContext
Original file line number Diff line number Diff line change @@ -76,7 +76,6 @@ func (self *MainViewController) Context() types.Context {
76
76
77
77
func (self * MainViewController ) togglePanel () error {
78
78
if self .otherContext .GetView ().Visible {
79
- self .otherContext .SetParentContext (self .context .GetParentContext ())
80
79
self .c .Context ().Push (self .otherContext , types.OnFocusOpts {})
81
80
}
82
81
@@ -89,15 +88,14 @@ func (self *MainViewController) escape() error {
89
88
}
90
89
91
90
func (self * MainViewController ) onClickInAlreadyFocusedView (opts gocui.ViewMouseBindingOpts ) error {
92
- parentCtx := self .context . GetParentContext ( )
93
- if parentCtx .GetOnClickFocusedMainView () != nil {
94
- return parentCtx .GetOnClickFocusedMainView ()(self .context .GetViewName (), opts .Y )
91
+ sidePanelContext := self .c . Context (). NextInStack ( self . context )
92
+ if sidePanelContext != nil && sidePanelContext .GetOnClickFocusedMainView () != nil {
93
+ return sidePanelContext .GetOnClickFocusedMainView ()(self .context .GetViewName (), opts .Y )
95
94
}
96
95
return nil
97
96
}
98
97
99
98
func (self * MainViewController ) onClickInOtherViewOfMainViewPair (opts gocui.ViewMouseBindingOpts ) error {
100
- self .context .SetParentContext (self .otherContext .GetParentContext ())
101
99
self .c .Context ().Push (self .context , types.OnFocusOpts {
102
100
ClickedWindowName : self .context .GetWindowName (),
103
101
ClickedViewLineIdx : opts .Y ,
Original file line number Diff line number Diff line change @@ -106,7 +106,9 @@ func (self *RenameSimilarityThresholdController) currentSidePanel() types.Contex
106
106
currentContext := self .c .Context ().CurrentStatic ()
107
107
if currentContext .GetKey () == context .NORMAL_MAIN_CONTEXT_KEY ||
108
108
currentContext .GetKey () == context .NORMAL_SECONDARY_CONTEXT_KEY {
109
- return currentContext .GetParentContext ()
109
+ if sidePanelContext := self .c .Context ().NextInStack (currentContext ); sidePanelContext != nil {
110
+ return sidePanelContext
111
+ }
110
112
}
111
113
112
114
return currentContext
Original file line number Diff line number Diff line change @@ -72,7 +72,6 @@ func (self *SwitchToFocusedMainViewController) handleFocusMainView() error {
72
72
}
73
73
74
74
func (self * SwitchToFocusedMainViewController ) focusMainView (mainViewContext types.Context ) error {
75
- mainViewContext .SetParentContext (self .context )
76
75
if context , ok := mainViewContext .(types.ISearchableContext ); ok {
77
76
context .ClearSearchString ()
78
77
}
Original file line number Diff line number Diff line change @@ -300,6 +300,7 @@ type IContextMgr interface {
300
300
CurrentStatic () Context
301
301
CurrentSide () Context
302
302
CurrentPopup () []Context
303
+ NextInStack (context Context ) Context
303
304
IsCurrent (c Context ) bool
304
305
IsCurrentOrParent (c Context ) bool
305
306
ForEach (func (Context ))
Original file line number Diff line number Diff line change @@ -152,9 +152,9 @@ func (gui *Gui) postRefreshUpdate(c types.Context) {
152
152
// just don't rerender the view while searching, on the assumption that users will probably
153
153
// either search or change their data, but not both at the same time.
154
154
if ! currentCtx .GetView ().IsSearching () {
155
- parentCtx := currentCtx . GetParentContext ( )
156
- if parentCtx .GetKey () == c .GetKey () {
157
- parentCtx .HandleRenderToMain ()
155
+ sidePanelContext := gui . State . ContextMgr . NextInStack ( currentCtx )
156
+ if sidePanelContext != nil && sidePanelContext .GetKey () == c .GetKey () {
157
+ sidePanelContext .HandleRenderToMain ()
158
158
}
159
159
}
160
160
}
You can’t perform that action at this time.
0 commit comments