mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
Replace PushContext() with Context().Push()
This commit is contained in:
parent
d89dc967b8
commit
bd36b8a95e
31 changed files with 36 additions and 41 deletions
|
@ -354,7 +354,7 @@ func (self *CommitFilesController) enterCommitFile(node *filetree.CommitFileNode
|
|||
}
|
||||
}
|
||||
|
||||
return self.c.PushContext(self.c.Contexts().CustomPatchBuilder, opts)
|
||||
return self.c.Context().Push(self.c.Contexts().CustomPatchBuilder, opts)
|
||||
}
|
||||
|
||||
if self.c.Git().Patch.PatchBuilder.Active() && self.c.Git().Patch.PatchBuilder.To != self.context().GetRef().RefName() {
|
||||
|
|
|
@ -220,7 +220,7 @@ func (self *CustomPatchOptionsMenuAction) handlePullPatchIntoNewCommit() error {
|
|||
if err := self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(err); err != nil {
|
||||
return err
|
||||
}
|
||||
return self.c.PushContext(self.c.Contexts().LocalCommits)
|
||||
return self.c.Context().Push(self.c.Contexts().LocalCommits)
|
||||
})
|
||||
},
|
||||
},
|
||||
|
|
|
@ -500,7 +500,7 @@ func (self *FilesController) EnterFile(opts types.OnFocusOpts) error {
|
|||
return errors.New(self.c.Tr.FileStagingRequirements)
|
||||
}
|
||||
|
||||
return self.c.PushContext(self.c.Contexts().Staging, opts)
|
||||
return self.c.Context().Push(self.c.Contexts().Staging, opts)
|
||||
}
|
||||
|
||||
func (self *FilesController) toggleStagedAll() error {
|
||||
|
|
|
@ -116,7 +116,7 @@ func (self *FilteringMenuAction) setFiltering() error {
|
|||
repoState.SetScreenMode(types.SCREEN_HALF)
|
||||
}
|
||||
|
||||
if err := self.c.PushContext(self.c.Contexts().LocalCommits); err != nil {
|
||||
if err := self.c.Context().Push(self.c.Contexts().LocalCommits); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ func (self *CommitsHelper) OpenCommitMessagePanel(opts *OpenCommitMessagePanelOp
|
|||
|
||||
self.UpdateCommitPanelView(opts.InitialMessage)
|
||||
|
||||
return self.c.PushContext(self.c.Contexts().CommitMessage)
|
||||
return self.c.Context().Push(self.c.Contexts().CommitMessage)
|
||||
}
|
||||
|
||||
func (self *CommitsHelper) OnCommitSuccess() {
|
||||
|
|
|
@ -241,7 +241,7 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ
|
|||
|
||||
self.c.State().GetRepoState().SetCurrentPopupOpts(&opts)
|
||||
|
||||
return self.c.PushContext(self.c.Contexts().Confirmation)
|
||||
return self.c.Context().Push(self.c.Contexts().Confirmation)
|
||||
}
|
||||
|
||||
func underlineLinks(text string) string {
|
||||
|
|
|
@ -137,7 +137,7 @@ func (self *FixupHelper) HandleFindBaseCommitForFixupPress() error {
|
|||
}
|
||||
|
||||
self.c.Contexts().LocalCommits.SetSelection(index)
|
||||
return self.c.PushContext(self.c.Contexts().LocalCommits)
|
||||
return self.c.Context().Push(self.c.Contexts().LocalCommits)
|
||||
}
|
||||
|
||||
if warnAboutAddedLines {
|
||||
|
|
|
@ -202,7 +202,7 @@ func (self *MergeAndRebaseHelper) PromptForConflictHandling() error {
|
|||
{
|
||||
Label: self.c.Tr.ViewConflictsMenuItem,
|
||||
OnPress: func() error {
|
||||
return self.c.PushContext(self.c.Contexts().Files)
|
||||
return self.c.Context().Push(self.c.Contexts().Files)
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -316,7 +316,7 @@ func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error {
|
|||
if err = self.ResetMarkedBaseCommit(); err != nil {
|
||||
return err
|
||||
}
|
||||
return self.c.PushContext(self.c.Contexts().LocalCommits)
|
||||
return self.c.Context().Push(self.c.Contexts().LocalCommits)
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -62,7 +62,7 @@ func (self *MergeConflictsHelper) EscapeMerge() error {
|
|||
// files context over it.
|
||||
// So long as both places call OnUIThread, we're fine.
|
||||
if self.c.IsCurrentContext(self.c.Contexts().MergeConflicts) {
|
||||
return self.c.PushContext(self.c.Contexts().Files)
|
||||
return self.c.Context().Push(self.c.Contexts().Files)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
@ -93,7 +93,7 @@ func (self *MergeConflictsHelper) SwitchToMerge(path string) error {
|
|||
}
|
||||
}
|
||||
|
||||
return self.c.PushContext(self.c.Contexts().MergeConflicts)
|
||||
return self.c.Context().Push(self.c.Contexts().MergeConflicts)
|
||||
}
|
||||
|
||||
func (self *MergeConflictsHelper) context() *context.MergeConflictsContext {
|
||||
|
|
|
@ -110,7 +110,7 @@ func (self *RefsHelper) CheckoutRemoteBranch(fullBranchName string, localBranchN
|
|||
// Switch to the branches context _before_ starting to check out the
|
||||
// branch, so that we see the inline status
|
||||
if self.c.CurrentContext() != self.c.Contexts().Branches {
|
||||
if err := self.c.PushContext(self.c.Contexts().Branches); err != nil {
|
||||
if err := self.c.Context().Push(self.c.Contexts().Branches); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggest
|
|||
}
|
||||
|
||||
if self.c.CurrentContext() != self.c.Contexts().Branches {
|
||||
if err := self.c.PushContext(self.c.Contexts().Branches); err != nil {
|
||||
if err := self.c.Context().Push(self.c.Contexts().Branches); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ func (self *SearchHelper) OpenFilterPrompt(context types.IFilterableContext) err
|
|||
self.OnPromptContentChanged("")
|
||||
promptView.RenderTextArea()
|
||||
|
||||
if err := self.c.PushContext(self.c.Contexts().Search); err != nil {
|
||||
if err := self.c.Context().Push(self.c.Contexts().Search); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ func (self *SearchHelper) OpenSearchPrompt(context types.ISearchableContext) err
|
|||
promptView.ClearTextArea()
|
||||
promptView.RenderTextArea()
|
||||
|
||||
if err := self.c.PushContext(self.c.Contexts().Search); err != nil {
|
||||
if err := self.c.Context().Push(self.c.Contexts().Search); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -83,11 +83,11 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) erro
|
|||
}
|
||||
|
||||
if mainState == nil && !secondaryFocused {
|
||||
return self.c.PushContext(secondaryContext, focusOpts)
|
||||
return self.c.Context().Push(secondaryContext, focusOpts)
|
||||
}
|
||||
|
||||
if secondaryState == nil && secondaryFocused {
|
||||
return self.c.PushContext(mainContext, focusOpts)
|
||||
return self.c.Context().Push(mainContext, focusOpts)
|
||||
}
|
||||
|
||||
if secondaryFocused {
|
||||
|
@ -110,7 +110,7 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) erro
|
|||
}
|
||||
|
||||
func (self *StagingHelper) handleStagingEscape() error {
|
||||
return self.c.PushContext(self.c.Contexts().Files)
|
||||
return self.c.Context().Push(self.c.Contexts().Files)
|
||||
}
|
||||
|
||||
func (self *StagingHelper) secondaryStagingFocused() bool {
|
||||
|
|
|
@ -72,5 +72,5 @@ func (self *SubCommitsHelper) ViewSubCommits(opts ViewSubCommitsOpts) error {
|
|||
return err
|
||||
}
|
||||
|
||||
return self.c.PushContext(self.c.Contexts().SubCommits)
|
||||
return self.c.Context().Push(self.c.Contexts().SubCommits)
|
||||
}
|
||||
|
|
|
@ -55,6 +55,6 @@ func (self *JumpToSideWindowController) goToSideWindow(window string) func() err
|
|||
|
||||
context := self.c.Helpers().Window.GetContextForWindow(window)
|
||||
|
||||
return self.c.PushContext(context)
|
||||
return self.c.Context().Push(context)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ func (self *ListController) HandleClick(opts gocui.ViewMouseBindingOpts) error {
|
|||
|
||||
func (self *ListController) pushContextIfNotFocused() error {
|
||||
if !self.isFocused() {
|
||||
if err := self.c.PushContext(self.context); err != nil {
|
||||
if err := self.c.Context().Push(self.context); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ func (self *PatchExplorerController) GetMouseKeybindings(opts types.KeybindingsO
|
|||
return self.withRenderAndFocus(self.HandleMouseDown)()
|
||||
}
|
||||
|
||||
return self.c.PushContext(self.context, types.OnFocusOpts{
|
||||
return self.c.Context().Push(self.context, types.OnFocusOpts{
|
||||
ClickedWindowName: self.context.GetWindowName(),
|
||||
ClickedViewLineIdx: opts.Y,
|
||||
})
|
||||
|
|
|
@ -74,7 +74,7 @@ func (self *QuitActions) Escape() error {
|
|||
parentContext, hasParent := currentContext.GetParentContext()
|
||||
if hasParent && currentContext != nil && parentContext != nil {
|
||||
// TODO: think about whether this should be marked as a return rather than adding to the stack
|
||||
return self.c.PushContext(parentContext)
|
||||
return self.c.Context().Push(parentContext)
|
||||
}
|
||||
|
||||
for _, mode := range self.c.Helpers().Mode.Statuses() {
|
||||
|
|
|
@ -131,7 +131,7 @@ func (self *RemotesController) enter(remote *models.Remote) error {
|
|||
return err
|
||||
}
|
||||
|
||||
return self.c.PushContext(remoteBranchesContext)
|
||||
return self.c.Context().Push(remoteBranchesContext)
|
||||
}
|
||||
|
||||
func (self *RemotesController) add() error {
|
||||
|
|
|
@ -69,7 +69,7 @@ func (self *SideWindowController) previousSideWindow() error {
|
|||
|
||||
context := self.c.Helpers().Window.GetContextForWindow(newWindow)
|
||||
|
||||
return self.c.PushContext(context)
|
||||
return self.c.Context().Push(context)
|
||||
}
|
||||
|
||||
func (self *SideWindowController) nextSideWindow() error {
|
||||
|
@ -92,5 +92,5 @@ func (self *SideWindowController) nextSideWindow() error {
|
|||
|
||||
context := self.c.Helpers().Window.GetContextForWindow(newWindow)
|
||||
|
||||
return self.c.PushContext(context)
|
||||
return self.c.Context().Push(context)
|
||||
}
|
||||
|
|
|
@ -75,5 +75,5 @@ func (self *SnakeController) SetDirection(direction snake.Direction) func() erro
|
|||
}
|
||||
|
||||
func (self *SnakeController) Escape() error {
|
||||
return self.c.PushContext(self.c.Contexts().Submodules)
|
||||
return self.c.Context().Push(self.c.Contexts().Submodules)
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ func (self *StagingController) Escape() error {
|
|||
|
||||
func (self *StagingController) TogglePanel() error {
|
||||
if self.otherContext.GetState() != nil {
|
||||
return self.c.PushContext(self.otherContext)
|
||||
return self.c.Context().Push(self.otherContext)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -113,7 +113,7 @@ func (self *StatusController) onClick(opts gocui.ViewMouseBindingOpts) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if err := self.c.PushContext(self.Context()); err != nil {
|
||||
if err := self.c.Context().Push(self.Context()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ func (self *SubmodulesController) remove(submodule *models.SubmoduleConfig) erro
|
|||
}
|
||||
|
||||
func (self *SubmodulesController) easterEgg() error {
|
||||
return self.c.PushContext(self.c.Contexts().Snake)
|
||||
return self.c.Context().Push(self.c.Contexts().Snake)
|
||||
}
|
||||
|
||||
func (self *SubmodulesController) context() *context.SubmodulesContext {
|
||||
|
|
|
@ -89,7 +89,7 @@ func (self *SwitchToDiffFilesController) viewFiles(opts SwitchToCommitFilesConte
|
|||
return err
|
||||
}
|
||||
|
||||
return self.c.PushContext(diffFilesContext)
|
||||
return self.c.Context().Push(diffFilesContext)
|
||||
}
|
||||
|
||||
func (self *SwitchToDiffFilesController) itemRepresentsCommit(ref types.Ref) *types.DisabledReason {
|
||||
|
|
|
@ -115,7 +115,7 @@ func (self *TagsController) checkout(tag *models.Tag) error {
|
|||
if err := self.c.Helpers().Refs.CheckoutRef(tag.FullRefName(), types.CheckoutRefOptions{}); err != nil {
|
||||
return err
|
||||
}
|
||||
return self.c.PushContext(self.c.Contexts().Branches)
|
||||
return self.c.Context().Push(self.c.Contexts().Branches)
|
||||
}
|
||||
|
||||
func (self *TagsController) localDelete(tag *models.Tag) error {
|
||||
|
|
|
@ -40,7 +40,7 @@ func (gui *Gui) handleFocusCommandLog() error {
|
|||
gui.c.State().SetShowExtrasWindow(true)
|
||||
// TODO: is this necessary? Can't I just call 'return from context'?
|
||||
gui.State.Contexts.CommandLog.SetParentContext(gui.c.CurrentSideContext())
|
||||
return gui.c.PushContext(gui.State.Contexts.CommandLog)
|
||||
return gui.c.Context().Push(gui.State.Contexts.CommandLog)
|
||||
}
|
||||
|
||||
func (gui *Gui) scrollUpExtra() error {
|
||||
|
|
|
@ -335,7 +335,7 @@ func (gui *Gui) onNewRepo(startArgs appTypes.StartArgs, contextKey types.Context
|
|||
}
|
||||
}
|
||||
|
||||
if err := gui.c.PushContext(contextToPush); err != nil {
|
||||
if err := gui.c.Context().Push(contextToPush); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -45,10 +45,6 @@ func (self *guiCommon) RunSubprocess(cmdObj oscommands.ICmdObj) (bool, error) {
|
|||
return self.gui.runSubprocessWithSuspense(cmdObj)
|
||||
}
|
||||
|
||||
func (self *guiCommon) PushContext(context types.Context, opts ...types.OnFocusOpts) error {
|
||||
return self.gui.State.ContextMgr.Push(context, opts...)
|
||||
}
|
||||
|
||||
func (self *guiCommon) PopContext() error {
|
||||
return self.gui.State.ContextMgr.Pop()
|
||||
}
|
||||
|
|
|
@ -60,5 +60,5 @@ func (gui *Gui) createMenu(opts types.CreateMenuOptions) error {
|
|||
_ = gui.c.PostRefreshUpdate(gui.State.Contexts.Menu)
|
||||
|
||||
// TODO: ensure that if we're opened a menu from within a menu that it renders correctly
|
||||
return gui.c.PushContext(gui.State.Contexts.Menu)
|
||||
return gui.c.Context().Push(gui.State.Contexts.Menu)
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ type IGuiCommon interface {
|
|||
RunSubprocess(cmdObj oscommands.ICmdObj) (bool, error)
|
||||
RunSubprocessAndRefresh(oscommands.ICmdObj) error
|
||||
|
||||
PushContext(context Context, opts ...OnFocusOpts) error
|
||||
PopContext() error
|
||||
ReplaceContext(context Context) error
|
||||
// Removes all given contexts from the stack. If a given context is not in the stack, it is ignored.
|
||||
|
|
|
@ -78,7 +78,7 @@ func (gui *Gui) onViewTabClick(windowName string, tabIndex int) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
return gui.c.PushContext(context)
|
||||
return gui.c.Context().Push(context)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleNextTab() error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue