mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-08 22:36:49 +02:00
@ -55,17 +55,7 @@ func (self *ContextMgr) Replace(c types.Context) {
|
||||
self.Activate(c, types.OnFocusOpts{})
|
||||
}
|
||||
|
||||
func (self *ContextMgr) Push(c types.Context, opts ...types.OnFocusOpts) {
|
||||
if len(opts) > 1 {
|
||||
panic("cannot pass multiple opts to Push")
|
||||
}
|
||||
|
||||
singleOpts := types.OnFocusOpts{}
|
||||
if len(opts) > 0 {
|
||||
// using triple dot but you should only ever pass one of these opt structs
|
||||
singleOpts = opts[0]
|
||||
}
|
||||
|
||||
func (self *ContextMgr) Push(c types.Context, opts types.OnFocusOpts) {
|
||||
if !c.IsFocusable() {
|
||||
return
|
||||
}
|
||||
@ -77,7 +67,7 @@ func (self *ContextMgr) Push(c types.Context, opts ...types.OnFocusOpts) {
|
||||
}
|
||||
|
||||
if contextToActivate != nil {
|
||||
self.Activate(contextToActivate, singleOpts)
|
||||
self.Activate(contextToActivate, opts)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ func (self *CustomPatchOptionsMenuAction) handlePullPatchIntoNewCommit() error {
|
||||
if err := self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(err); err != nil {
|
||||
return err
|
||||
}
|
||||
self.c.Context().Push(self.c.Contexts().LocalCommits)
|
||||
self.c.Context().Push(self.c.Contexts().LocalCommits, types.OnFocusOpts{})
|
||||
return nil
|
||||
})
|
||||
},
|
||||
|
@ -120,7 +120,7 @@ func (self *FilteringMenuAction) setFiltering() error {
|
||||
repoState.SetScreenMode(types.SCREEN_HALF)
|
||||
}
|
||||
|
||||
self.c.Context().Push(self.c.Contexts().LocalCommits)
|
||||
self.c.Context().Push(self.c.Contexts().LocalCommits, types.OnFocusOpts{})
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() error {
|
||||
self.c.Contexts().LocalCommits.SetSelection(0)
|
||||
|
@ -12,10 +12,6 @@ import (
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
type ICommitsHelper interface {
|
||||
UpdateCommitPanelView(message string)
|
||||
}
|
||||
|
||||
type CommitsHelper struct {
|
||||
c *HelperCommon
|
||||
|
||||
@ -26,8 +22,6 @@ type CommitsHelper struct {
|
||||
setCommitDescription func(string)
|
||||
}
|
||||
|
||||
var _ ICommitsHelper = &CommitsHelper{}
|
||||
|
||||
func NewCommitsHelper(
|
||||
c *HelperCommon,
|
||||
getCommitSummary func() string,
|
||||
@ -150,7 +144,7 @@ func (self *CommitsHelper) OpenCommitMessagePanel(opts *OpenCommitMessagePanelOp
|
||||
|
||||
self.UpdateCommitPanelView(opts.InitialMessage)
|
||||
|
||||
self.c.Context().Push(self.c.Contexts().CommitMessage)
|
||||
self.c.Context().Push(self.c.Contexts().CommitMessage, types.OnFocusOpts{})
|
||||
}
|
||||
|
||||
func (self *CommitsHelper) OnCommitSuccess() {
|
||||
|
@ -177,7 +177,7 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ
|
||||
|
||||
self.c.State().GetRepoState().SetCurrentPopupOpts(&opts)
|
||||
|
||||
self.c.Context().Push(self.c.Contexts().Confirmation)
|
||||
self.c.Context().Push(self.c.Contexts().Confirmation, types.OnFocusOpts{})
|
||||
}
|
||||
|
||||
func (self *ConfirmationHelper) setKeyBindings(cancel goContext.CancelFunc, opts types.CreatePopupPanelOpts) {
|
||||
|
@ -6,12 +6,6 @@ import (
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
type IFilesHelper interface {
|
||||
EditFiles(filenames []string) error
|
||||
EditFileAtLine(filename string, lineNumber int) error
|
||||
OpenFile(filename string) error
|
||||
}
|
||||
|
||||
type FilesHelper struct {
|
||||
c *HelperCommon
|
||||
}
|
||||
@ -22,8 +16,6 @@ func NewFilesHelper(c *HelperCommon) *FilesHelper {
|
||||
}
|
||||
}
|
||||
|
||||
var _ IFilesHelper = &FilesHelper{}
|
||||
|
||||
func (self *FilesHelper) EditFiles(filenames []string) error {
|
||||
absPaths := lo.Map(filenames, func(filename string, _ int) string {
|
||||
absPath, err := filepath.Abs(filename)
|
||||
|
@ -137,7 +137,7 @@ func (self *FixupHelper) HandleFindBaseCommitForFixupPress() error {
|
||||
}
|
||||
|
||||
self.c.Contexts().LocalCommits.SetSelection(index)
|
||||
self.c.Context().Push(self.c.Contexts().LocalCommits)
|
||||
self.c.Context().Push(self.c.Contexts().LocalCommits, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -6,11 +6,6 @@ import (
|
||||
|
||||
// this helper just wraps our hosting_service package
|
||||
|
||||
type IHostHelper interface {
|
||||
GetPullRequestURL(from string, to string) (string, error)
|
||||
GetCommitURL(commitHash string) (string, error)
|
||||
}
|
||||
|
||||
type HostHelper struct {
|
||||
c *HelperCommon
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ func (self *MergeAndRebaseHelper) PromptForConflictHandling() error {
|
||||
{
|
||||
Label: self.c.Tr.ViewConflictsMenuItem,
|
||||
OnPress: func() error {
|
||||
self.c.Context().Push(self.c.Contexts().Files)
|
||||
self.c.Context().Push(self.c.Contexts().Files, types.OnFocusOpts{})
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@ -357,7 +357,7 @@ func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error {
|
||||
if err = self.ResetMarkedBaseCommit(); err != nil {
|
||||
return err
|
||||
}
|
||||
self.c.Context().Push(self.c.Contexts().LocalCommits)
|
||||
self.c.Context().Push(self.c.Contexts().LocalCommits, types.OnFocusOpts{})
|
||||
return nil
|
||||
},
|
||||
},
|
||||
|
@ -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.Context().IsCurrent(self.c.Contexts().MergeConflicts) {
|
||||
self.c.Context().Push(self.c.Contexts().Files)
|
||||
self.c.Context().Push(self.c.Contexts().Files, types.OnFocusOpts{})
|
||||
}
|
||||
return nil
|
||||
})
|
||||
@ -93,7 +93,7 @@ func (self *MergeConflictsHelper) SwitchToMerge(path string) error {
|
||||
}
|
||||
}
|
||||
|
||||
self.c.Context().Push(self.c.Contexts().MergeConflicts)
|
||||
self.c.Context().Push(self.c.Contexts().MergeConflicts, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -9,10 +9,6 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
)
|
||||
|
||||
type IPatchBuildingHelper interface {
|
||||
ValidateNormalWorkingTreeState() (bool, error)
|
||||
}
|
||||
|
||||
type PatchBuildingHelper struct {
|
||||
c *HelperCommon
|
||||
}
|
||||
|
@ -14,15 +14,6 @@ import (
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
type IRefsHelper interface {
|
||||
CheckoutRef(ref string, options types.CheckoutRefOptions) error
|
||||
GetCheckedOutRef() *models.Branch
|
||||
CreateGitResetMenu(ref string) error
|
||||
CreateCheckoutMenu(commit *models.Commit) error
|
||||
ResetToRef(ref string, strength string, envVars []string) error
|
||||
NewBranch(from string, fromDescription string, suggestedBranchname string) error
|
||||
}
|
||||
|
||||
type RefsHelper struct {
|
||||
c *HelperCommon
|
||||
}
|
||||
@ -35,8 +26,6 @@ func NewRefsHelper(
|
||||
}
|
||||
}
|
||||
|
||||
var _ IRefsHelper = &RefsHelper{}
|
||||
|
||||
func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions) error {
|
||||
waitingStatus := options.WaitingStatus
|
||||
if waitingStatus == "" {
|
||||
@ -118,7 +107,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.Context().Current() != self.c.Contexts().Branches {
|
||||
self.c.Context().Push(self.c.Contexts().Branches)
|
||||
self.c.Context().Push(self.c.Contexts().Branches, types.OnFocusOpts{})
|
||||
}
|
||||
return self.CheckoutRef(branchName, types.CheckoutRefOptions{})
|
||||
}
|
||||
@ -334,7 +323,7 @@ func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggest
|
||||
|
||||
refresh := func() error {
|
||||
if self.c.Context().Current() != self.c.Contexts().Branches {
|
||||
self.c.Context().Push(self.c.Contexts().Branches)
|
||||
self.c.Context().Push(self.c.Contexts().Branches, types.OnFocusOpts{})
|
||||
}
|
||||
|
||||
self.c.Contexts().LocalCommits.SetSelection(0)
|
||||
|
@ -41,7 +41,7 @@ func (self *SearchHelper) OpenFilterPrompt(context types.IFilterableContext) err
|
||||
self.OnPromptContentChanged("")
|
||||
promptView.RenderTextArea()
|
||||
|
||||
self.c.Context().Push(self.c.Contexts().Search)
|
||||
self.c.Context().Push(self.c.Contexts().Search, types.OnFocusOpts{})
|
||||
|
||||
return self.c.ResetKeybindings()
|
||||
}
|
||||
@ -58,7 +58,7 @@ func (self *SearchHelper) OpenSearchPrompt(context types.ISearchableContext) err
|
||||
promptView.ClearTextArea()
|
||||
promptView.RenderTextArea()
|
||||
|
||||
self.c.Context().Push(self.c.Contexts().Search)
|
||||
self.c.Context().Push(self.c.Contexts().Search, types.OnFocusOpts{})
|
||||
|
||||
return self.c.ResetKeybindings()
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) {
|
||||
}
|
||||
|
||||
func (self *StagingHelper) handleStagingEscape() {
|
||||
self.c.Context().Push(self.c.Contexts().Files)
|
||||
self.c.Context().Push(self.c.Contexts().Files, types.OnFocusOpts{})
|
||||
}
|
||||
|
||||
func (self *StagingHelper) secondaryStagingFocused() bool {
|
||||
|
@ -69,6 +69,6 @@ func (self *SubCommitsHelper) ViewSubCommits(opts ViewSubCommitsOpts) error {
|
||||
|
||||
self.c.PostRefreshUpdate(self.c.Contexts().SubCommits)
|
||||
|
||||
self.c.Context().Push(self.c.Contexts().SubCommits)
|
||||
self.c.Context().Push(self.c.Contexts().SubCommits, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
|
@ -26,20 +26,10 @@ import (
|
||||
// finding suggestions in this file, so that it's easy to see if a function already
|
||||
// exists for fetching a particular model.
|
||||
|
||||
type ISuggestionsHelper interface {
|
||||
GetRemoteSuggestionsFunc() func(string) []*types.Suggestion
|
||||
GetBranchNameSuggestionsFunc() func(string) []*types.Suggestion
|
||||
GetFilePathSuggestionsFunc() func(string) []*types.Suggestion
|
||||
GetRemoteBranchesSuggestionsFunc(separator string) func(string) []*types.Suggestion
|
||||
GetRefsSuggestionsFunc() func(string) []*types.Suggestion
|
||||
}
|
||||
|
||||
type SuggestionsHelper struct {
|
||||
c *HelperCommon
|
||||
}
|
||||
|
||||
var _ ISuggestionsHelper = &SuggestionsHelper{}
|
||||
|
||||
func NewSuggestionsHelper(
|
||||
c *HelperCommon,
|
||||
) *SuggestionsHelper {
|
||||
|
@ -14,15 +14,6 @@ type UpstreamHelper struct {
|
||||
getRemoteBranchesSuggestionsFunc func(string) func(string) []*types.Suggestion
|
||||
}
|
||||
|
||||
type IUpstreamHelper interface {
|
||||
ParseUpstream(string) (string, string, error)
|
||||
PromptForUpstreamWithInitialContent(*models.Branch, func(string) error) error
|
||||
PromptForUpstreamWithoutInitialContent(*models.Branch, func(string) error) error
|
||||
GetSuggestedRemote() string
|
||||
}
|
||||
|
||||
var _ IUpstreamHelper = &UpstreamHelper{}
|
||||
|
||||
func NewUpstreamHelper(
|
||||
c *HelperCommon,
|
||||
getRemoteBranchesSuggestionsFunc func(string) func(string) []*types.Suggestion,
|
||||
|
@ -12,13 +12,6 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
)
|
||||
|
||||
type IWorkingTreeHelper interface {
|
||||
AnyStagedFiles() bool
|
||||
AnyTrackedFiles() bool
|
||||
IsWorkingTreeDirty() bool
|
||||
FileForSubmodule(submodule *models.SubmoduleConfig) *models.File
|
||||
}
|
||||
|
||||
type WorkingTreeHelper struct {
|
||||
c *HelperCommon
|
||||
refHelper *RefsHelper
|
||||
|
@ -12,11 +12,6 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
)
|
||||
|
||||
type IWorktreeHelper interface {
|
||||
GetMainWorktreeName() string
|
||||
GetCurrentWorktreeName() string
|
||||
}
|
||||
|
||||
type WorktreeHelper struct {
|
||||
c *HelperCommon
|
||||
reposHelper *ReposHelper
|
||||
|
@ -56,7 +56,7 @@ func (self *JumpToSideWindowController) goToSideWindow(window string) func() err
|
||||
|
||||
context := self.c.Helpers().Window.GetContextForWindow(window)
|
||||
|
||||
self.c.Context().Push(context)
|
||||
self.c.Context().Push(context, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ func (self *ListController) HandleClick(opts gocui.ViewMouseBindingOpts) error {
|
||||
|
||||
func (self *ListController) pushContextIfNotFocused() error {
|
||||
if !self.isFocused() {
|
||||
self.c.Context().Push(self.context)
|
||||
self.c.Context().Push(self.context, types.OnFocusOpts{})
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -79,7 +79,7 @@ func (self *QuitActions) Escape() error {
|
||||
parentContext := currentContext.GetParentContext()
|
||||
if parentContext != nil {
|
||||
// TODO: think about whether this should be marked as a return rather than adding to the stack
|
||||
self.c.Context().Push(parentContext)
|
||||
self.c.Context().Push(parentContext, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ func (self *RemotesController) enter(remote *models.Remote) error {
|
||||
|
||||
self.c.PostRefreshUpdate(remoteBranchesContext)
|
||||
|
||||
self.c.Context().Push(remoteBranchesContext)
|
||||
self.c.Context().Push(remoteBranchesContext, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ func (self *SideWindowController) previousSideWindow() error {
|
||||
|
||||
context := self.c.Helpers().Window.GetContextForWindow(newWindow)
|
||||
|
||||
self.c.Context().Push(context)
|
||||
self.c.Context().Push(context, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -93,6 +93,6 @@ func (self *SideWindowController) nextSideWindow() error {
|
||||
|
||||
context := self.c.Helpers().Window.GetContextForWindow(newWindow)
|
||||
|
||||
self.c.Context().Push(context)
|
||||
self.c.Context().Push(context, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
|
@ -73,6 +73,6 @@ func (self *SnakeController) SetDirection(direction snake.Direction) func() erro
|
||||
}
|
||||
|
||||
func (self *SnakeController) Escape() error {
|
||||
self.c.Context().Push(self.c.Contexts().Submodules)
|
||||
self.c.Context().Push(self.c.Contexts().Submodules, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ func (self *StagingController) Escape() error {
|
||||
|
||||
func (self *StagingController) TogglePanel() error {
|
||||
if self.otherContext.GetState() != nil {
|
||||
self.c.Context().Push(self.otherContext)
|
||||
self.c.Context().Push(self.otherContext, types.OnFocusOpts{})
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -112,7 +112,7 @@ func (self *StashController) handleStashApply(stashEntry *models.StashEntry) err
|
||||
return err
|
||||
}
|
||||
if self.c.UserConfig().Gui.SwitchToFilesAfterStashApply {
|
||||
self.c.Context().Push(self.c.Contexts().Files)
|
||||
self.c.Context().Push(self.c.Contexts().Files, types.OnFocusOpts{})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -141,7 +141,7 @@ func (self *StashController) handleStashPop(stashEntry *models.StashEntry) error
|
||||
return err
|
||||
}
|
||||
if self.c.UserConfig().Gui.SwitchToFilesAfterStashPop {
|
||||
self.c.Context().Push(self.c.Contexts().Files)
|
||||
self.c.Context().Push(self.c.Contexts().Files, types.OnFocusOpts{})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ func (self *StatusController) onClick(opts gocui.ViewMouseBindingOpts) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
self.c.Context().Push(self.Context())
|
||||
self.c.Context().Push(self.Context(), types.OnFocusOpts{})
|
||||
|
||||
upstreamStatus := utils.Decolorise(presentation.BranchStatus(currentBranch, types.ItemOperationNone, self.c.Tr, time.Now(), self.c.UserConfig()))
|
||||
repoName := self.c.Git().RepoPaths.RepoName()
|
||||
|
@ -309,7 +309,7 @@ func (self *SubmodulesController) remove(submodule *models.SubmoduleConfig) erro
|
||||
}
|
||||
|
||||
func (self *SubmodulesController) easterEgg() error {
|
||||
self.c.Context().Push(self.c.Contexts().Snake)
|
||||
self.c.Context().Push(self.c.Contexts().Snake, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ func (self *SwitchToDiffFilesController) enter() error {
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.Context().Push(commitFilesContext)
|
||||
self.c.Context().Push(commitFilesContext, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
self.c.Context().Push(self.c.Contexts().Branches)
|
||||
self.c.Context().Push(self.c.Contexts().Branches, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,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.Context().CurrentSide())
|
||||
gui.c.Context().Push(gui.State.Contexts.CommandLog)
|
||||
gui.c.Context().Push(gui.State.Contexts.CommandLog, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ func (gui *Gui) onNewRepo(startArgs appTypes.StartArgs, contextKey types.Context
|
||||
}
|
||||
}
|
||||
|
||||
gui.c.Context().Push(contextToPush)
|
||||
gui.c.Context().Push(contextToPush, types.OnFocusOpts{})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -60,6 +60,6 @@ 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
|
||||
gui.c.Context().Push(gui.State.Contexts.Menu)
|
||||
gui.c.Context().Push(gui.State.Contexts.Menu, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ type ListItem interface {
|
||||
}
|
||||
|
||||
type IContextMgr interface {
|
||||
Push(context Context, opts ...OnFocusOpts)
|
||||
Push(context Context, opts OnFocusOpts)
|
||||
Pop()
|
||||
Replace(context Context)
|
||||
Activate(context Context, opts OnFocusOpts)
|
||||
|
@ -72,7 +72,7 @@ func (gui *Gui) onViewTabClick(windowName string, tabIndex int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
gui.c.Context().Push(context)
|
||||
gui.c.Context().Push(context, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user