From 46c53ea34ffc9db5f078ca400af3a994f8c01e68 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 9 Mar 2026 08:16:46 +0100 Subject: [PATCH 1/2] Cleanup: use CurrentSide() instead of private currentSidePanel They both do the same. --- pkg/gui/controllers/context_lines_controller.go | 14 +------------- .../rename_similarity_threshold_controller.go | 14 +------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/pkg/gui/controllers/context_lines_controller.go b/pkg/gui/controllers/context_lines_controller.go index b2484f6d0..a1ce9f518 100644 --- a/pkg/gui/controllers/context_lines_controller.go +++ b/pkg/gui/controllers/context_lines_controller.go @@ -75,7 +75,7 @@ func (self *ContextLinesController) Decrease() error { func (self *ContextLinesController) applyChange() error { self.c.Toast(fmt.Sprintf(self.c.Tr.DiffContextSizeChanged, self.c.UserConfig().Git.DiffContextSize)) - currentContext := self.currentSidePanel() + currentContext := self.c.Context().CurrentSide() switch currentContext.GetKey() { // we make an exception for our staging and patch building contexts because they actually need to refresh their state afterwards. case context.PATCH_BUILDING_MAIN_CONTEXT_KEY: @@ -95,15 +95,3 @@ func (self *ContextLinesController) checkCanChangeContext() error { return nil } - -func (self *ContextLinesController) currentSidePanel() types.Context { - currentContext := self.c.Context().CurrentStatic() - if currentContext.GetKey() == context.NORMAL_MAIN_CONTEXT_KEY || - currentContext.GetKey() == context.NORMAL_SECONDARY_CONTEXT_KEY { - if sidePanelContext := self.c.Context().NextInStack(currentContext); sidePanelContext != nil { - return sidePanelContext - } - } - - return currentContext -} diff --git a/pkg/gui/controllers/rename_similarity_threshold_controller.go b/pkg/gui/controllers/rename_similarity_threshold_controller.go index 522785a04..2d5f52bc0 100644 --- a/pkg/gui/controllers/rename_similarity_threshold_controller.go +++ b/pkg/gui/controllers/rename_similarity_threshold_controller.go @@ -71,7 +71,7 @@ func (self *RenameSimilarityThresholdController) Decrease() error { func (self *RenameSimilarityThresholdController) applyChange() error { self.c.Toast(fmt.Sprintf(self.c.Tr.RenameSimilarityThresholdChanged, self.c.UserConfig().Git.RenameSimilarityThreshold)) - currentContext := self.currentSidePanel() + currentContext := self.c.Context().CurrentSide() switch currentContext.GetKey() { // we make an exception for our files context, because it actually need to refresh its state afterwards. case context.FILES_CONTEXT_KEY: @@ -81,15 +81,3 @@ func (self *RenameSimilarityThresholdController) applyChange() error { } return nil } - -func (self *RenameSimilarityThresholdController) currentSidePanel() types.Context { - currentContext := self.c.Context().CurrentStatic() - if currentContext.GetKey() == context.NORMAL_MAIN_CONTEXT_KEY || - currentContext.GetKey() == context.NORMAL_SECONDARY_CONTEXT_KEY { - if sidePanelContext := self.c.Context().NextInStack(currentContext); sidePanelContext != nil { - return sidePanelContext - } - } - - return currentContext -} From 5b23f80398916d825c66b069b233f74126626eb9 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 8 Mar 2026 20:20:26 +0100 Subject: [PATCH 2/2] Re-render main view when changing screen mode This is needed for diffs in case a custom pager is used and its output depends on the window width (e.g. the horizontal lines in delta). --- pkg/gui/controllers/screen_mode_actions.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/gui/controllers/screen_mode_actions.go b/pkg/gui/controllers/screen_mode_actions.go index 190aad604..a09331065 100644 --- a/pkg/gui/controllers/screen_mode_actions.go +++ b/pkg/gui/controllers/screen_mode_actions.go @@ -41,6 +41,11 @@ func (self *ScreenModeActions) rerenderViewsWithScreenModeDependentContent() { self.rerenderView(context.GetView()) } } + + // Rerender the main view; for views that display a diff this is necessary in case a custom + // pager depends on the width of the view. For other views it isn't needed, but we don't bother + // making a distinction here, as rerendering the main view unnecessarily is not a big deal. + self.c.Context().CurrentSide().HandleRenderToMain() } func (self *ScreenModeActions) rerenderView(view *gocui.View) {