summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-04-15 14:36:25 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-04-30 13:19:53 +1000
commit5a7b2ab6d04ee5def0898e9a9ca9f36f602b2017 (patch)
tree5c7cd7539b24a0118e6054760a80562b73a27c98 /pkg
parent68a9d7fd773135b59d4eccf439bfe0e28a13cb81 (diff)
fix rendering of commit files view
Diffstat (limited to 'pkg')
-rw-r--r--pkg/gui/context/commit_files_context.go43
-rw-r--r--pkg/gui/controllers/commits_files_controller.go32
2 files changed, 32 insertions, 43 deletions
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 {