diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-12-30 23:24:24 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-04-30 13:19:52 +1000 |
commit | 8edad826caf2fa48bfad33f9f8c4f3ba49a052da (patch) | |
tree | 0b49145e4f656e72441199b5a5c30176c898d7a7 /pkg/gui/commit_files_panel.go | |
parent | 826128a8e03fb50f7287029ebac93c85712faecb (diff) |
Begin refactoring gui
This begins a big refactor of moving more code out of the Gui struct into contexts, controllers, and helpers. We also move some code into structs in the
gui package purely for the sake of better encapsulation
Diffstat (limited to 'pkg/gui/commit_files_panel.go')
-rw-r--r-- | pkg/gui/commit_files_panel.go | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go deleted file mode 100644 index d88b95495..000000000 --- a/pkg/gui/commit_files_panel.go +++ /dev/null @@ -1,52 +0,0 @@ -package gui - -import ( - "github.com/jesseduffield/lazygit/pkg/gui/controllers" - "github.com/jesseduffield/lazygit/pkg/gui/types" -) - -func (gui *Gui) commitFilesRenderToMain() error { - node := gui.State.Contexts.CommitFiles.GetSelected() - if node == nil { - return nil - } - - ref := gui.State.Contexts.CommitFiles.GetRef() - to := ref.RefName() - from, reverse := gui.State.Modes.Diffing.GetFromAndReverseArgsForDiff(ref.ParentRefName()) - - cmdObj := gui.git.WorkingTree.ShowFileDiffCmdObj(from, to, reverse, node.GetPath(), false, - gui.IgnoreWhitespaceInDiffView) - task := types.NewRunPtyTask(cmdObj.GetCmd()) - - pair := gui.c.MainViewPairs().Normal - if node.File != nil { - pair = gui.c.MainViewPairs().PatchBuilding - } - - return gui.c.RenderToMainViews(types.RefreshMainOpts{ - Pair: pair, - Main: &types.ViewUpdateOpts{ - Title: gui.Tr.Patch, - Task: task, - }, - Secondary: gui.secondaryPatchPanelUpdateOpts(), - }) -} - -func (gui *Gui) SwitchToCommitFilesContext(opts controllers.SwitchToCommitFilesContextOpts) error { - gui.State.Contexts.CommitFiles.SetSelectedLineIdx(0) - gui.State.Contexts.CommitFiles.SetRef(opts.Ref) - gui.State.Contexts.CommitFiles.SetTitleRef(opts.Ref.Description()) - gui.State.Contexts.CommitFiles.SetCanRebase(opts.CanRebase) - gui.State.Contexts.CommitFiles.SetParentContext(opts.Context) - gui.State.Contexts.CommitFiles.SetWindowName(opts.Context.GetWindowName()) - - if err := gui.c.Refresh(types.RefreshOptions{ - Scope: []types.RefreshableView{types.COMMIT_FILES}, - }); err != nil { - return err - } - - return gui.c.PushContext(gui.State.Contexts.CommitFiles) -} |