From 5a7b2ab6d04ee5def0898e9a9ca9f36f602b2017 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 15 Apr 2023 14:36:25 +1000 Subject: fix rendering of commit files view --- pkg/gui/context/commit_files_context.go | 43 ------------------------- pkg/gui/controllers/commits_files_controller.go | 32 ++++++++++++++++++ 2 files changed, 32 insertions(+), 43 deletions(-) (limited to 'pkg') diff --git a/pkg/gui/context/commit_files_context.go b/pkg/gui/context/commit_files_context.go index 0b884a7cd..96b6f2fcf 100644 --- a/pkg/gui/context/commit_files_context.go +++ b/pkg/gui/context/commit_files_context.go @@ -71,46 +71,3 @@ func (self *CommitFilesContext) GetSelectedItemId() string { func (self *CommitFilesContext) GetDiffTerminals() []string { return []string{self.GetRef().RefName()} } - -func (self *CommitFilesContext) renderToMain() error { - node := self.GetSelected() - if node == nil { - return nil - } - - ref := self.GetRef() - to := ref.RefName() - from, reverse := self.c.Modes().Diffing.GetFromAndReverseArgsForDiff(ref.ParentRefName()) - - cmdObj := self.c.Git().WorkingTree.ShowFileDiffCmdObj( - from, to, reverse, node.GetPath(), false, self.c.State().GetIgnoreWhitespaceInDiffView(), - ) - task := types.NewRunPtyTask(cmdObj.GetCmd()) - - pair := self.c.MainViewPairs().Normal - if node.File != nil { - pair = self.c.MainViewPairs().PatchBuilding - } - - return self.c.RenderToMainViews(types.RefreshMainOpts{ - Pair: pair, - Main: &types.ViewUpdateOpts{ - Title: self.c.Tr.Patch, - Task: task, - }, - Secondary: secondaryPatchPanelUpdateOpts(self.c), - }) -} - -func secondaryPatchPanelUpdateOpts(c *ContextCommon) *types.ViewUpdateOpts { - if c.Git().Patch.PatchBuilder.Active() { - patch := c.Git().Patch.PatchBuilder.RenderAggregatedPatch(false) - - return &types.ViewUpdateOpts{ - Task: types.NewRenderStringWithoutScrollTask(patch), - Title: c.Tr.CustomPatch, - } - } - - return nil -} diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index 8ef5f2c57..b7f53ec69 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -102,6 +102,38 @@ func (self *CommitFilesController) context() *context.CommitFilesContext { return self.c.Contexts().CommitFiles } +func (self *CommitFilesController) GetOnRenderToMain() func() error { + return func() error { + node := self.context().GetSelected() + if node == nil { + return nil + } + + ref := self.context().GetRef() + to := ref.RefName() + from, reverse := self.c.Modes().Diffing.GetFromAndReverseArgsForDiff(ref.ParentRefName()) + + cmdObj := self.c.Git().WorkingTree.ShowFileDiffCmdObj( + from, to, reverse, node.GetPath(), false, self.c.State().GetIgnoreWhitespaceInDiffView(), + ) + task := types.NewRunPtyTask(cmdObj.GetCmd()) + + pair := self.c.MainViewPairs().Normal + if node.File != nil { + pair = self.c.MainViewPairs().PatchBuilding + } + + return self.c.RenderToMainViews(types.RefreshMainOpts{ + Pair: pair, + Main: &types.ViewUpdateOpts{ + Title: self.c.Tr.Patch, + Task: task, + }, + Secondary: secondaryPatchPanelUpdateOpts(self.c), + }) + } +} + func (self *CommitFilesController) onClickMain(opts gocui.ViewMouseBindingOpts) error { node := self.context().GetSelected() if node == nil { -- cgit v1.2.3