summaryrefslogtreecommitdiffstats
path: root/pkg/gui/controllers/commits_files_controller.go
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/gui/controllers/commits_files_controller.go
parent68a9d7fd773135b59d4eccf439bfe0e28a13cb81 (diff)
fix rendering of commit files view
Diffstat (limited to 'pkg/gui/controllers/commits_files_controller.go')
-rw-r--r--pkg/gui/controllers/commits_files_controller.go32
1 files changed, 32 insertions, 0 deletions
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 {