1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-19 00:28:03 +02:00

Replace CurrentContext() with Context().Current()

This commit is contained in:
Stefan Haller
2024-08-08 10:26:55 +02:00
parent 8e15451117
commit 7ed94c0410
23 changed files with 24 additions and 29 deletions

View File

@ -178,7 +178,7 @@ func (self *CommitFilesController) checkout(node *filetree.CommitFileNode) error
}
func (self *CommitFilesController) discard(selectedNodes []*filetree.CommitFileNode) error {
parentContext, ok := self.c.CurrentContext().GetParentContext()
parentContext, ok := self.c.Context().Current().GetParentContext()
if !ok || parentContext.GetKey() != context.LOCAL_COMMITS_CONTEXT_KEY {
return errors.New(self.c.Tr.CanOnlyDiscardFromLocalCommits)
}

View File

@ -66,7 +66,7 @@ func (self *CustomPatchOptionsMenuAction) Call() error {
},
}...)
if self.c.CurrentContext().GetKey() == self.c.Contexts().LocalCommits.GetKey() {
if self.c.Context().Current().GetKey() == self.c.Contexts().LocalCommits.GetKey() {
selectedCommit := self.c.Contexts().LocalCommits.GetSelected()
if selectedCommit != nil && self.c.Git().Patch.PatchBuilder.To != selectedCommit.Hash {
@ -122,7 +122,7 @@ func (self *CustomPatchOptionsMenuAction) validateNormalWorkingTreeState() (bool
}
func (self *CustomPatchOptionsMenuAction) returnFocusFromPatchExplorerIfNecessary() error {
if self.c.CurrentContext().GetKey() == self.c.Contexts().CustomPatchBuilder.GetKey() {
if self.c.Context().Current().GetKey() == self.c.Contexts().CustomPatchBuilder.GetKey() {
return self.c.Helpers().PatchBuilding.Escape()
}
return nil

View File

@ -431,7 +431,7 @@ func (self *ConfirmationHelper) IsPopupPanel(context types.Context) bool {
}
func (self *ConfirmationHelper) IsPopupPanelFocused() bool {
return self.IsPopupPanel(self.c.CurrentContext())
return self.IsPopupPanel(self.c.Context().Current())
}
func (self *ConfirmationHelper) TooltipForMenuItem(menuItem *types.MenuItem) string {

View File

@ -93,7 +93,7 @@ func (self *DiffHelper) currentDiffTerminal() string {
}
func (self *DiffHelper) currentlySelectedFilename() string {
currentContext := self.c.CurrentContext()
currentContext := self.c.Context().Current()
switch currentContext := currentContext.(type) {
case types.IListContext:

View File

@ -123,7 +123,7 @@ func (self *MergeConflictsHelper) RefreshMergeState() error {
self.c.Contexts().MergeConflicts.GetMutex().Lock()
defer self.c.Contexts().MergeConflicts.GetMutex().Unlock()
if self.c.CurrentContext().GetKey() != context.MERGE_CONFLICTS_CONTEXT_KEY {
if self.c.Context().Current().GetKey() != context.MERGE_CONFLICTS_CONTEXT_KEY {
return nil
}

View File

@ -54,7 +54,7 @@ func (self *PatchBuildingHelper) Reset() error {
}
// refreshing the current context so that the secondary panel is hidden if necessary.
return self.c.PostRefreshUpdate(self.c.CurrentContext())
return self.c.PostRefreshUpdate(self.c.Context().Current())
}
func (self *PatchBuildingHelper) RefreshPatchBuildingPanel(opts types.OnFocusOpts) error {

View File

@ -109,7 +109,7 @@ func (self *RefsHelper) CheckoutRemoteBranch(fullBranchName string, localBranchN
checkout := func(branchName string) error {
// 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 self.c.Context().Current() != self.c.Contexts().Branches {
if err := self.c.Context().Push(self.c.Contexts().Branches); err != nil {
return err
}
@ -292,7 +292,7 @@ func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggest
return err
}
if self.c.CurrentContext() != self.c.Contexts().Branches {
if self.c.Context().Current() != self.c.Contexts().Branches {
if err := self.c.Context().Push(self.c.Contexts().Branches); err != nil {
return err
}

View File

@ -262,7 +262,7 @@ func (self *SearchHelper) ReApplySearch(ctx types.Context) {
if ctx == state.Context {
// Re-render the "x of y" search status, unless the search prompt is
// open for typing.
if self.c.CurrentContext().GetKey() != context.SEARCH_CONTEXT_KEY {
if self.c.Context().Current().GetKey() != context.SEARCH_CONTEXT_KEY {
self.RenderSearchStatus(searchableContext)
}
}

View File

@ -61,7 +61,7 @@ func (self *WindowHelper) windowViewNameMap() *utils.ThreadSafeMap[string, strin
}
func (self *WindowHelper) CurrentWindow() string {
return self.c.CurrentContext().GetWindowName()
return self.c.Context().Current().GetWindowName()
}
// assumes the context's windowName has been set to the new window if necessary

View File

@ -185,7 +185,7 @@ func (self *ListController) pushContextIfNotFocused() error {
}
func (self *ListController) isFocused() bool {
return self.c.CurrentContext().GetKey() == self.context.GetKey()
return self.c.Context().Current().GetKey() == self.context.GetKey()
}
func (self *ListController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding {

View File

@ -12,7 +12,7 @@ type OptionsMenuAction struct {
}
func (self *OptionsMenuAction) Call() error {
ctx := self.c.CurrentContext()
ctx := self.c.Context().Current()
// Don't show menu while displaying popup.
if ctx.GetKind() == types.PERSISTENT_POPUP || ctx.GetKind() == types.TEMPORARY_POPUP {
return nil

View File

@ -293,7 +293,7 @@ func (self *PatchExplorerController) CopySelectedToClipboard() error {
}
func (self *PatchExplorerController) isFocused() bool {
return self.c.CurrentContext().GetKey() == self.context.GetKey()
return self.c.Context().Current().GetKey() == self.context.GetKey()
}
func (self *PatchExplorerController) withRenderAndFocus(f func() error) func() error {

View File

@ -49,7 +49,7 @@ func (self *QuitActions) confirmQuitDuringUpdate() error {
}
func (self *QuitActions) Escape() error {
currentContext := self.c.CurrentContext()
currentContext := self.c.Context().Current()
if listContext, ok := currentContext.(types.IListContext); ok {
if listContext.GetList().IsSelectingRange() {

View File

@ -19,7 +19,7 @@ func (self *ToggleWhitespaceAction) Call() error {
context.PATCH_BUILDING_MAIN_CONTEXT_KEY,
}
if lo.Contains(contextsThatDontSupportIgnoringWhitespace, self.c.CurrentContext().GetKey()) {
if lo.Contains(contextsThatDontSupportIgnoringWhitespace, self.c.Context().Current().GetKey()) {
// Ignoring whitespace is not supported in these views. Let the user
// know that it's not going to work in case they try to turn it on.
return errors.New(self.c.Tr.IgnoreWhitespaceNotSupportedHere)