Fix diff display of custom pagers after screen mode change (#5349)

We need to re-render the main view after a screen mode change, in case a
custom pager is being used and its output depends on the window width.
This commit is contained in:
Stefan Haller 2026-03-09 19:44:37 +01:00 committed by GitHub
commit 43fa7a499e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 26 deletions

View file

@ -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
}

View file

@ -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
}

View file

@ -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) {