From 2c91bd99d6173741079ef2226e5ebe3158d9a790 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 25 Sep 2026 15:05:42 +0200 Subject: [PATCH] Move re-rendering the main view after a diff renderer change to a helper The next commit needs to render the diff again when the terminal switches between dark and light, with the same care not to replace whatever else the main view might show. Co-Authored-By: Claude Opus 5.5 (1M context) --- pkg/gui/controllers/global_controller.go | 9 +-------- pkg/gui/controllers/helpers/diff_helper.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pkg/gui/controllers/global_controller.go b/pkg/gui/controllers/global_controller.go index b50ec6d1d..f4de89567 100644 --- a/pkg/gui/controllers/global_controller.go +++ b/pkg/gui/controllers/global_controller.go @@ -3,7 +3,6 @@ package controllers import ( "strconv" - "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" ) @@ -185,13 +184,7 @@ func (self *GlobalController) cycleDiffRenderersBackward() error { // onDiffRenderersChanged re-renders the main view so the newly selected diff renderer // takes effect, and shows a toast naming it. func (self *GlobalController) onDiffRenderersChanged() { - currentSide := self.c.Context().CurrentSide() - currentKey := self.c.Context().Current().GetKey() - if currentSide.GetKey() == currentKey || - currentKey == context.NORMAL_MAIN_CONTEXT_KEY || - currentKey == context.NORMAL_SECONDARY_CONTEXT_KEY { - currentSide.HandleRenderToMain() - } + self.c.Helpers().Diff.RenderToMainAgain() diffRendererConfigManager := self.c.State().GetDiffRendererConfigManager() current, total := diffRendererConfigManager.CurrentDiffRendererIndex() diff --git a/pkg/gui/controllers/helpers/diff_helper.go b/pkg/gui/controllers/helpers/diff_helper.go index 8433cd75f..02d8f005c 100644 --- a/pkg/gui/controllers/helpers/diff_helper.go +++ b/pkg/gui/controllers/helpers/diff_helper.go @@ -98,6 +98,19 @@ func (self *DiffHelper) ExitDiffMode() error { return nil } +// RenderToMainAgain renders the current side panel into the main view again, if +// that is what the main view shows. This is for when something that the +// rendering depends on has changed, such as the diff renderer. +func (self *DiffHelper) RenderToMainAgain() { + currentSide := self.c.Context().CurrentSide() + currentKey := self.c.Context().Current().GetKey() + if currentSide.GetKey() == currentKey || + currentKey == context.NORMAL_MAIN_CONTEXT_KEY || + currentKey == context.NORMAL_SECONDARY_CONTEXT_KEY { + currentSide.HandleRenderToMain() + } +} + func (self *DiffHelper) RenderDiff() { args := self.DiffArgs() cmdObj := self.c.Git().Diff.DiffCmdObj(args)