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)