diff options
Diffstat (limited to 'pkg/gui/controllers')
33 files changed, 259 insertions, 283 deletions
diff --git a/pkg/gui/controllers/basic_commits_controller.go b/pkg/gui/controllers/basic_commits_controller.go index cecba00fe..340b14c0b 100644 --- a/pkg/gui/controllers/basic_commits_controller.go +++ b/pkg/gui/controllers/basic_commits_controller.go @@ -141,7 +141,7 @@ func (self *BasicCommitsController) copyCommitAttribute(commit *models.Commit) e func (self *BasicCommitsController) copyCommitSHAToClipboard(commit *models.Commit) error { self.c.LogAction(self.c.Tr.Actions.CopyCommitSHAToClipboard) - if err := self.os.CopyToClipboard(commit.Sha); err != nil { + if err := self.c.OS().CopyToClipboard(commit.Sha); err != nil { return self.c.Error(err) } @@ -156,7 +156,7 @@ func (self *BasicCommitsController) copyCommitURLToClipboard(commit *models.Comm } self.c.LogAction(self.c.Tr.Actions.CopyCommitURLToClipboard) - if err := self.os.CopyToClipboard(url); err != nil { + if err := self.c.OS().CopyToClipboard(url); err != nil { return self.c.Error(err) } @@ -165,13 +165,13 @@ func (self *BasicCommitsController) copyCommitURLToClipboard(commit *models.Comm } func (self *BasicCommitsController) copyCommitDiffToClipboard(commit *models.Commit) error { - diff, err := self.git.Commit.GetCommitDiff(commit.Sha) + diff, err := self.c.Git().Commit.GetCommitDiff(commit.Sha) if err != nil { return self.c.Error(err) } self.c.LogAction(self.c.Tr.Actions.CopyCommitDiffToClipboard) - if err := self.os.CopyToClipboard(diff); err != nil { + if err := self.c.OS().CopyToClipboard(diff); err != nil { return self.c.Error(err) } @@ -180,7 +180,7 @@ func (self *BasicCommitsController) copyCommitDiffToClipboard(commit *models.Com } func (self *BasicCommitsController) copyAuthorToClipboard(commit *models.Commit) error { - author, err := self.git.Commit.GetCommitAuthor(commit.Sha) + author, err := self.c.Git().Commit.GetCommitAuthor(commit.Sha) if err != nil { return self.c.Error(err) } @@ -188,7 +188,7 @@ func (self *BasicCommitsController) copyAuthorToClipboard(commit *models.Commit) formattedAuthor := fmt.Sprintf("%s <%s>", author.Name, author.Email) self.c.LogAction(self.c.Tr.Actions.CopyCommitAuthorToClipboard) - if err := self.os.CopyToClipboard(formattedAuthor); err != nil { + if err := self.c.OS().CopyToClipboard(formattedAuthor); err != nil { return self.c.Error(err) } @@ -197,13 +197,13 @@ func (self *BasicCommitsController) copyAuthorToClipboard(commit *models.Commit) } func (self *BasicCommitsController) copyCommitMessageToClipboard(commit *models.Commit) error { - message, err := self.git.Commit.GetCommitMessage(commit.Sha) + message, err := self.c.Git().Commit.GetCommitMessage(commit.Sha) if err != nil { return self.c.Error(err) } self.c.LogAction(self.c.Tr.Actions.CopyCommitMessageToClipboard) - if err := self.os.CopyToClipboard(message); err != nil { + if err := self.c.OS().CopyToClipboard(message); err != nil { return self.c.Error(err) } @@ -218,7 +218,7 @@ func (self *BasicCommitsController) openInBrowser(commit *models.Commit) error { } self.c.LogAction(self.c.Tr.Actions.OpenCommitInBrowser) - if err := self.os.OpenLink(url); err != nil { + if err := self.c.OS().OpenLink(url); err != nil { return self.c.Error(err) } diff --git a/pkg/gui/controllers/bisect_controller.go b/pkg/gui/controllers/bisect_controller.go index 083b6dce8..6531b1409 100644 --- a/pkg/gui/controllers/bisect_controller.go +++ b/pkg/gui/controllers/bisect_controller.go @@ -42,7 +42,7 @@ func (self *BisectController) GetKeybindings(opts types.KeybindingsOpts) []*type func (self *BisectController) openMenu(commit *models.Commit) error { // no shame in getting this directly rather than using the cached value // given how cheap it is to obtain - info := self.git.Bisect.GetInfo() + info := self.c.Git().Bisect.GetInfo() if info.Started() { return self.openMidBisectMenu(info, commit) } else { @@ -63,14 +63,14 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c selectCurrentAfter := info.GetCurrentSha() == "" || info.GetCurrentSha() == commit.Sha // we need to wait to reselect if our bisect commits aren't ancestors of our 'start' // ref, because we'll be reloading our commits in that case. - waitToReselect := selectCurrentAfter && !self.git.Bisect.ReachableFromStart(info) + waitToReselect := selectCurrentAfter && !self.c.Git().Bisect.ReachableFromStart(info) menuItems := []*types.MenuItem{ { Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortSha(), info.NewTerm()), OnPress: func() error { self.c.LogAction(self.c.Tr.Actions.BisectMark) - if err := self.git.Bisect.Mark(commit.Sha, info.NewTerm()); err != nil { + if err := self.c.Git().Bisect.Mark(commit.Sha, info.NewTerm()); err != nil { return self.c.Error(err) } @@ -82,7 +82,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortSha(), info.OldTerm()), OnPress: func() error { self.c.LogAction(self.c.Tr.Actions.BisectMark) - if err := self.git.Bisect.Mark(commit.Sha, info.OldTerm()); err != nil { + if err := self.c.Git().Bisect.Mark(commit.Sha, info.OldTerm()); err != nil { return self.c.Error(err) } @@ -94,7 +94,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c Label: fmt.Sprintf(self.c.Tr.Bisect.Skip, commit.ShortSha()), OnPress: func() error { self.c.LogAction(self.c.Tr.Actions.BisectSkip) - if err := self.git.Bisect.Skip(commit.Sha); err != nil { + if err := self.c.Git().Bisect.Skip(commit.Sha); err != nil { return self.c.Error(err) } @@ -125,11 +125,11 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo, Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortSha(), info.NewTerm()), OnPress: func() error { self.c.LogAction(self.c.Tr.Actions.StartBisect) - if err := self.git.Bisect.Start(); err != nil { + if err := self.c.Git().Bisect.Start(); err != nil { return self.c.Error(err) } - if err := self.git.Bisect.Mark(commit.Sha, info.NewTerm()); err != nil { + if err := self.c.Git().Bisect.Mark(commit.Sha, info.NewTerm()); err != nil { return self.c.Error(err) } @@ -141,11 +141,11 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo, Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortSha(), info.OldTerm()), OnPress: func() error { self.c.LogAction(self.c.Tr.Actions.StartBisect) - if err := self.git.Bisect.Start(); err != nil { + if err := self.c.Git().Bisect.Start(); err != nil { return self.c.Error(err) } - if err := self.git.Bisect.Mark(commit.Sha, info.OldTerm()); err != nil { + if err := self.c.Git().Bisect.Mark(commit.Sha, info.OldTerm()); err != nil { return self.c.Error(err) } @@ -163,7 +163,7 @@ func (self *BisectController) showBisectCompleteMessage(candidateShas []string) prompt = self.c.Tr.Bisect.CompletePromptIndeterminate } - formattedCommits, err := self.git.Commit.GetCommitsOneline(candidateShas) + formattedCommits, err := self.c.Git().Commit.GetCommitsOneline(candidateShas) if err != nil { return self.c.Error(err) } @@ -173,7 +173,7 @@ func (self *BisectController) showBisectCompleteMessage(candidateShas []string) Prompt: fmt.Sprintf(prompt, strings.TrimSpace(formattedCommits)), HandleConfirm: func() error { self.c.LogAction(self.c.Tr.Actions.ResetBisect) - if err := self.git.Bisect.Reset(); err != nil { + if err := self.c.Git().Bisect.Reset(); err != nil { return self.c.Error(err) } @@ -183,7 +183,7 @@ func (self *BisectController) showBisectCompleteMessage(candidateShas []string) } func (self *BisectController) afterMark(selectCurrent bool, waitToReselect bool) error { - done, candidateShas, err := self.git.Bisect.IsDone() + done, candidateShas, err := self.c.Git().Bisect.IsDone() if err != nil { return self.c.Error(err) } @@ -216,10 +216,10 @@ func (self *BisectController) afterBisectMarkRefresh(selectCurrent bool, waitToR } func (self *BisectController) selectCurrentBisectCommit() { - info := self.git.Bisect.GetInfo() + info := self.c.Git().Bisect.GetInfo() if info.GetCurrentSha() != "" { // find index of commit with that sha, move cursor to that. - for i, commit := range self.model.Commits { + for i, commit := range self.c.Model().Commits { if commit.Sha == info.GetCurrentSha() { self.context().SetSelectedLineIdx(i) _ = self.context().HandleFocus(types.OnFocusOpts{}) @@ -245,5 +245,5 @@ func (self *BisectController) Context() types.Context { } func (self *BisectController) context() *context.LocalCommitsContext { - return self.contexts.LocalCommits + return self.c.Contexts().LocalCommits } diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go index 27b3004c8..03e088368 100644 --- a/pkg/gui/controllers/branches_controller.go +++ b/pkg/gui/controllers/branches_controller.go @@ -142,7 +142,7 @@ func (self *BranchesController) setUpstream(selectedBranch *models.Branch) error { LabelColumns: []string{self.c.Tr.LcUnsetUpstream}, OnPress: func() error { - if err := self.git.Branch.UnsetUpstream(selectedBranch.Name); err != nil { + if err := self.c.Git().Branch.UnsetUpstream(selectedBranch.Name); err != nil { return self.c.Error(err) } if err := self.c.Refresh(types.RefreshOptions{ @@ -167,7 +167,7 @@ func (self *BranchesController) setUpstream(selectedBranch *models.Branch) error return self.c.Error(err) } - if err := self.git.Branch.SetUpstream(upstreamRemote, upstreamBranch, selectedBranch.Name); err != nil { + if err := self.c.Git().Branch.SetUpstream(upstreamRemote, upstreamBranch, selectedBranch.Name); err != nil { return self.c.Error(err) } if err := self.c.Refresh(types.RefreshOptions{ @@ -193,7 +193,7 @@ func (self *BranchesController) Context() types.Context { } func (self *BranchesController) context() *context.BranchesContext { - return self.contexts.Branches + return self.c.Contexts().Branches } func (self *BranchesController) press(selectedBranch *models.Branch) error { @@ -218,7 +218,7 @@ func (self *BranchesController) handleCreatePullRequestMenu(selectedBranch *mode func (self *BranchesController) copyPullRequestURL() error { branch := self.context().GetSelected() - branchExistsOnRemote := self.git.Remote.CheckRemoteBranchExists(branch.Name) + branchExistsOnRemote := self.c.Git().Remote.CheckRemoteBranchExists(branch.Name) if !branchExistsOnRemote { return self.c.Error(errors.New(self.c.Tr.NoBranchOnRemote)) @@ -229,7 +229,7 @@ func (self *BranchesController) copyPullRequestURL() error { return self.c.Error(err) } self.c.LogAction(self.c.Tr.Actions.CopyPullRequestURL) - if err := self.os.CopyToClipboard(url); err != nil { + if err := self.c.OS().CopyToClipboard(url); err != nil { return self.c.Error(err) } @@ -248,7 +248,7 @@ func (self *BranchesController) forceCheckout() error { Prompt: message, HandleConfirm: func() error { self.c.LogAction(self.c.Tr.Actions.ForceCheckoutBranch) - if err := self.git.Branch.Checkout(branch.Name, git_commands.CheckoutOptions{Force: true}); err != nil { + if err := self.c.Git().Branch.Checkout(branch.Name, git_commands.CheckoutOptions{Force: true}); err != nil { _ = self.c.Error(err) } return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) @@ -284,7 +284,7 @@ func (self *BranchesController) createNewBranchWithName(newBranchName string) er return nil } - if err := self.git.Branch.New(newBranchName, branch.FullRefName()); err != nil { + if err := self.c.Git().Branch.New(newBranchName, branch.FullRefName()); err != nil { return self.c.Error(err) } @@ -320,7 +320,7 @@ func (self *BranchesController) deleteWithForce(selectedBranch *models.Branch, f Prompt: message, HandleConfirm: func() error { self.c.LogAction(self.c.Tr.Actions.DeleteBranch) - if err := self.git.Branch.Delete(selectedBranch.Name, force); err != nil { + if err := self.c.Git().Branch.Delete(selectedBranch.Name, force); err != nil { errMessage := err.Error() if !force && strings.Contains(errMessage, "git branch -D ") { return self.deleteWithForce(selectedBranch, true) @@ -367,7 +367,7 @@ func (self *BranchesController) fastForward(branch *models.Branch) error { if branch == self.helpers.Refs.GetCheckedOutRef() { self.c.LogAction(action) - err := self.git.Sync.Pull( + err := self.c.Git().Sync.Pull( git_commands.PullOptions{ RemoteName: branch.UpstreamRemote, BranchName: branch.UpstreamBranch, @@ -381,7 +381,7 @@ func (self *BranchesController) fastForward(branch *models.Branch) error { return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) } else { self.c.LogAction(action) - err := self.git.Sync.FastForward(branch.Name, branch.UpstreamRemote, branch.UpstreamBranch) + err := self.c.Git().Sync.FastForward(branch.Name, branch.UpstreamRemote, branch.UpstreamBranch) if err != nil { _ = self.c.Error(err) } @@ -407,7 +407,7 @@ func (self *BranchesController) rename(branch *models.Branch) error { InitialContent: branch.Name, HandleConfirm: func(newBranchName string) error { self.c.LogAction(self.c.Tr.Actions.RenameBranch) - if err := self.git.Branch.Rename(branch.Name, newBranchName); err != nil { + if err := self.c.Git().Branch.Rename(branch.Name, newBranchName); err != nil { return self.c.Error(err) } @@ -415,7 +415,7 @@ func (self *BranchesController) rename(branch *models.Branch) error { _ = self.c.Refresh(types.RefreshOptions{Mode: types.SYNC, Scope: []types.RefreshableView{types.BRANCHES}}) // now that we've got our stuff again we need to find that branch and reselect it. - for i, newBranch := range self.model.Branches { + for i, newBranch := range self.c.Model().Branches { if newBranch.Name == newBranchName { self.context().SetSelectedLineIdx(i) if err := self.context().HandleRender(); err != nil { @@ -502,7 +502,7 @@ func (self *BranchesController) createPullRequest(from string, to string) error self.c.LogAction(self.c.Tr.Actions.OpenPullRequest) - if err := self.os.OpenLink(url); err != nil { + if err := self.c.OS().OpenLink(url); err != nil { return self.c.Error(err) } diff --git a/pkg/gui/controllers/command_log_controller.go b/pkg/gui/controllers/command_log_controller.go index 45520edd9..3e6e7c11a 100644 --- a/pkg/gui/controllers/command_log_controller.go +++ b/pkg/gui/controllers/command_log_controller.go @@ -38,5 +38,5 @@ func (self *CommandLogController) Context() types.Context { } func (self *CommandLogController) context() types.Context { - return self.contexts.CommandLog + return self.c.Contexts().CommandLog } diff --git a/pkg/gui/controllers/commit_message_controller.go b/pkg/gui/controllers/commit_message_controller.go index 5db89b0e2..1b28ec887 100644 --- a/pkg/gui/controllers/commit_message_controller.go +++ b/pkg/gui/controllers/commit_message_controller.go @@ -65,7 +65,7 @@ func (self *CommitMessageController) Context() types.Context { // this method is pointless in this context but I'm keeping it consistent // with other contexts so that when generics arrive it's easier to refactor func (self *CommitMessageController) context() *context.CommitMessageContext { - return self.contexts.CommitMessage + return self.c.Contexts().CommitMessage } func (self *CommitMessageController) confirm() error { @@ -76,7 +76,7 @@ func (self *CommitMessageController) confirm() error { return self.c.ErrorMsg(self.c.Tr.CommitWithoutMessageErr) } - cmdObj := self.git.Commit.CommitCmdObj(message) + cmdObj := self.c.Git().Commit.CommitCmdObj(message) self.c.LogAction(self.c.Tr.Actions.Commit) _ = self.c.PopContext() diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index a5c5e667d..34e859211 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -99,7 +99,7 @@ func (self *CommitFilesController) Context() types.Context { } func (self *CommitFilesController) context() *context.CommitFilesContext { - return self.contexts.CommitFiles + return self.c.Contexts().CommitFiles } func (self *CommitFilesController) onClickMain(opts gocui.ViewMouseBindingOpts) error { @@ -112,7 +112,7 @@ func (self *CommitFilesController) onClickMain(opts gocui.ViewMouseBindingOpts) func (self *CommitFilesController) checkout(node *filetree.CommitFileNode) error { self.c.LogAction(self.c.Tr.Actions.CheckoutFile) - if err := self.git.WorkingTree.CheckoutFile(self.context().GetRef().RefName(), node.GetPath()); err != nil { + if err := self.c.Git().WorkingTree.CheckoutFile(self.context().GetRef().RefName(), node.GetPath()); err != nil { return self.c.Error(err) } @@ -130,7 +130,7 @@ func (self *CommitFilesController) discard(node *filetree.CommitFileNode) error HandleConfirm: func() error { return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func() error { self.c.LogAction(self.c.Tr.Actions.DiscardOldFileChange) - if err := self.git.Rebase.DiscardOldFileChanges(self.model.Commits, self.contexts.LocalCommits.GetSelectedLineIdx(), node.GetPath()); err != nil { + if err := self.c.Git().Rebase.DiscardOldFileChanges(self.c.Model().Commits, self.c.Contexts().LocalCommits.GetSelectedLineIdx(), node.GetPath()); err != nil { if err := self.helpers.MergeAndRebase.CheckMergeOrRebase(err); err != nil { return err } @@ -157,7 +157,7 @@ func (self *CommitFilesController) edit(node *filetree.CommitFileNode) error { func (self *CommitFilesController) toggleForPatch(node *filetree.CommitFileNode) error { toggle := func() error { return self.c.WithWaitingStatus(self.c.Tr.LcUpdatingPatch, func() error { - if !self.git.Patch.PatchBuilder.Active() { + if !self.c.Git().Patch.PatchBuilder.Active() { if err := self.startPatchBuilder(); err != nil { return err } @@ -166,34 +166,34 @@ func (self *CommitFilesController) toggleForPatch(node *filetree.CommitFileNode) // if there is any file that hasn't been fully added we'll fully add everything, // otherwise we'll remove everything adding := node.SomeFile(func(file *models.CommitFile) bool { - return self.git.Patch.PatchBuilder.GetFileStatus(file.Name, self.context().GetRef().RefName()) != patch.WHOLE + return self.c.Git().Patch.PatchBuilder.GetFileStatus(file.Name, self.context().GetRef().RefName()) != patch.WHOLE }) err := node.ForEachFile(func(file *models.CommitFile) error { if adding { - return self.git.Patch.PatchBuilder.AddFileWhole(file.Name) + return self.c.Git().Patch.PatchBuilder.AddFileWhole(file.Name) } else { - return self.git.Patch.PatchBuilder.RemoveFile(file.Name) + return self.c.Git().Patch.PatchBuilder.RemoveFile(file.Name) } }) if err != nil { return self.c.Error(err) } - if self.git.Patch.PatchBuilder.IsEmpty() { - self.git.Patch.PatchBuilder.Reset() + if self.c.Git().Patch.PatchBuilder.IsEmpty() { + self.c.Git().Patch.PatchBuilder.Reset() } return self.c.PostRefreshUpdate(self.context()) }) } - if self.git.Patch.PatchBuilder.Active() && self.git.Patch.PatchBuilder.To != self.context().GetRef().RefName() { + if self.c.Git().Patch.PatchBuilder.Active() && self.c.Git().Patch.PatchBuilder.To != self.context().GetRef().RefName() { return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DiscardPatch, Prompt: self.c.Tr.DiscardPatchConfirm, HandleConfirm: func() error { - self.git.Patch.PatchBuilder.Reset() + self.c.Git().Patch.PatchBuilder.Reset() return toggle() }, }) @@ -213,9 +213,9 @@ func (self *CommitFilesController) startPatchBuilder() error { canRebase := commitFilesContext.GetCanRebase() ref := commitFilesContext.GetRef() to := ref.RefName() - from, reverse := self.modes.Diffing.GetFromAndReverseArgsForDiff(ref.ParentRefName()) + from, reverse := self.c.Modes().Diffing.GetFromAndReverseArgsForDiff(ref.ParentRefName()) - self.git.Patch.PatchBuilder.Start(from, to, reverse, canRebase) + self.c.Git().Patch.PatchBuilder.Start(from, to, reverse, canRebase) return nil } @@ -229,21 +229,21 @@ func (self *CommitFilesController) enterCommitFile(node *filetree.CommitFileNode } enterTheFile := func() error { - if !self.git.Patch.PatchBuilder.Active() { + if !self.c.Git().Patch.PatchBuilder.Active() { if err := self.startPatchBuilder(); err != nil { return err } } - return self.c.PushContext(self.contexts.CustomPatchBuilder, opts) + return self.c.PushContext(self.c.Contexts().CustomPatchBuilder, opts) } - if self.git.Patch.PatchBuilder.Active() && self.git.Patch.PatchBuilder.To != self.context().GetRef().RefName() { + if self.c.Git().Patch.PatchBuilder.Active() && self.c.Git().Patch.PatchBuilder.To != self.context().GetRef().RefName() { return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DiscardPatch, Prompt: self.c.Tr.DiscardPatchConfirm, HandleConfirm: func() error { - self.git.Patch.PatchBuilder.Reset() + self.c.Git().Patch.PatchBuilder.Reset() return enterTheFile() }, }) diff --git a/pkg/gui/controllers/common.go b/pkg/gui/controllers/common.go index e1af81732..1c14b7f4e 100644 --- a/pkg/gui/controllers/common.go +++ b/pkg/gui/controllers/common.go @@ -1,48 +1,20 @@ package controllers import ( - "github.com/jesseduffield/lazygit/pkg/commands" - "github.com/jesseduffield/lazygit/pkg/commands/oscommands" - "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" - "github.com/jesseduffield/lazygit/pkg/gui/types" ) type controllerCommon struct { - c *helpers.HelperCommon - helpers *helpers.Helpers - contexts *context.ContextTree - - // TODO: use helperCommon's .OS() method instead of this - os *oscommands.OSCommand - // TODO: use helperCommon's .Git() method instead of this - git *commands.GitCommand - // TODO: use helperCommon's .Model() method instead of this - model *types.Model - // TODO: use helperCommon's .Modes() method instead of this - modes *types.Modes - // TODO: use helperCommon's .Mutexes() method instead of this - mutexes *types.Mutexes + c *helpers.HelperCommon + helpers *helpers.Helpers } func NewControllerCommon( c *helpers.HelperCommon, - os *oscommands.OSCommand, - git *commands.GitCommand, helpers *helpers.Helpers, - model *types.Model, - contexts *context.ContextTree, - modes *types.Modes, - mutexes *types.Mutexes, ) *controllerCommon { return &controllerCommon{ - c: c, - os: os, - git: git, - helpers: helpers, - model: model, - contexts: contexts, - modes: modes, - mutexes: mutexes, + c: c, + helpers: helpers, } } diff --git a/pkg/gui/controllers/confirmation_controller.go b/pkg/gui/controllers/confirmation_controller.go index 8b0d159da..09496f721 100644 --- a/pkg/gui/controllers/confirmation_controller.go +++ b/pkg/gui/controllers/confirmation_controller.go @@ -38,8 +38,8 @@ func (self *ConfirmationController) GetKeybindings(opts types.KeybindingsOpts) [ { Key: opts.GetKey(opts.Config.Universal.TogglePanel), Handler: func() error { - if len(self.contexts.Suggestions.State.Suggestions) > 0 { - return self.c.ReplaceContext(self.contexts.Suggestions) + if len(self.c.Contexts().Suggestions.State.Suggestions) > 0 { + return self.c.ReplaceContext(self.c.Contexts().Suggestions) } return nil }, @@ -61,5 +61,5 @@ func (self *ConfirmationController) Context() types.Context { } func (self *ConfirmationController) context() *context.ConfirmationContext { - return self.contexts.Confirmation + return self.c.Contexts().Confirmation } diff --git a/pkg/gui/controllers/context_lines_controller.go b/pkg/gui/controllers/context_lines_controller.go index 5a4fb291b..913b763d0 100644 --- a/pkg/gui/controllers/context_lines_controller.go +++ b/pkg/gui/controllers/context_lines_controller.go @@ -101,7 +101,7 @@ func (self *ContextLinesController) applyChange() error { } func (self *ContextLinesController) checkCanChangeContext() error { - if self.git.Patch.PatchBuilder.Active() { + if self.c.Git().Patch.PatchBuilder.Active() { return errors.New(self.c.Tr.CantChangeContextSizeError) } diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index 4d3740b77..7d040704a 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -208,7 +208,7 @@ func (self *FilesController) GetOnRenderToMain() func() error { split := self.c.UserConfig.Gui.SplitDiff == "always" || (node |