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 {
357357 return context .GetKind () == types .TEMPORARY_POPUP || context .GetKind () == types .PERSISTENT_POPUP
358358 })
359359}
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 {
131131 currentContext := self .c .Context ().CurrentStatic ()
132132 if currentContext .GetKey () == context .NORMAL_MAIN_CONTEXT_KEY ||
133133 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+ }
135137 }
136138
137139 return currentContext
Original file line number Diff line number Diff line change @@ -76,7 +76,6 @@ func (self *MainViewController) Context() types.Context {
7676
7777func (self * MainViewController ) togglePanel () error {
7878 if self .otherContext .GetView ().Visible {
79- self .otherContext .SetParentContext (self .context .GetParentContext ())
8079 self .c .Context ().Push (self .otherContext , types.OnFocusOpts {})
8180 }
8281
@@ -89,15 +88,14 @@ func (self *MainViewController) escape() error {
8988}
9089
9190func (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 )
9594 }
9695 return nil
9796}
9897
9998func (self * MainViewController ) onClickInOtherViewOfMainViewPair (opts gocui.ViewMouseBindingOpts ) error {
100- self .context .SetParentContext (self .otherContext .GetParentContext ())
10199 self .c .Context ().Push (self .context , types.OnFocusOpts {
102100 ClickedWindowName : self .context .GetWindowName (),
103101 ClickedViewLineIdx : opts .Y ,
Original file line number Diff line number Diff line change @@ -106,7 +106,9 @@ func (self *RenameSimilarityThresholdController) currentSidePanel() types.Contex
106106 currentContext := self .c .Context ().CurrentStatic ()
107107 if currentContext .GetKey () == context .NORMAL_MAIN_CONTEXT_KEY ||
108108 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+ }
110112 }
111113
112114 return currentContext
Original file line number Diff line number Diff line change @@ -72,7 +72,6 @@ func (self *SwitchToFocusedMainViewController) handleFocusMainView() error {
7272}
7373
7474func (self * SwitchToFocusedMainViewController ) focusMainView (mainViewContext types.Context ) error {
75- mainViewContext .SetParentContext (self .context )
7675 if context , ok := mainViewContext .(types.ISearchableContext ); ok {
7776 context .ClearSearchString ()
7877 }
Original file line number Diff line number Diff line change @@ -300,6 +300,7 @@ type IContextMgr interface {
300300 CurrentStatic () Context
301301 CurrentSide () Context
302302 CurrentPopup () []Context
303+ NextInStack (context Context ) Context
303304 IsCurrent (c Context ) bool
304305 IsCurrentOrParent (c Context ) bool
305306 ForEach (func (Context ))
Original file line number Diff line number Diff line change @@ -152,9 +152,9 @@ func (gui *Gui) postRefreshUpdate(c types.Context) {
152152 // just don't rerender the view while searching, on the assumption that users will probably
153153 // either search or change their data, but not both at the same time.
154154 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 ()
158158 }
159159 }
160160 }
You can’t perform that action at this time.
0 commit comments