mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-24 19:39:16 +02:00
Show context-specific labels for the global <esc> binding
WHen several modes are active at the same time, it isn't totally obvious which one will be cancelled first, so show this in the status bar.
This commit is contained in:
@@ -119,6 +119,7 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: self.escape,
|
||||
Description: self.c.Tr.Cancel,
|
||||
DescriptionFunc: self.escapeDescription,
|
||||
GetDisabledReason: self.escapeEnabled,
|
||||
DisplayOnScreen: true,
|
||||
},
|
||||
@@ -191,6 +192,10 @@ func (self *GlobalController) escape() error {
|
||||
return (&QuitActions{c: self.c}).Escape()
|
||||
}
|
||||
|
||||
func (self *GlobalController) escapeDescription() string {
|
||||
return (&QuitActions{c: self.c}).EscapeDescription()
|
||||
}
|
||||
|
||||
func (self *GlobalController) escapeEnabled() *types.DisabledReason {
|
||||
if (&QuitActions{c: self.c}).EscapeEnabled() {
|
||||
return nil
|
||||
|
@@ -39,9 +39,10 @@ func NewModeHelper(
|
||||
}
|
||||
|
||||
type ModeStatus struct {
|
||||
IsActive func() bool
|
||||
InfoLabel func() string
|
||||
Reset func() error
|
||||
IsActive func() bool
|
||||
InfoLabel func() string
|
||||
CancelLabel func() string
|
||||
Reset func() error
|
||||
}
|
||||
|
||||
func (self *ModeHelper) Statuses() []ModeStatus {
|
||||
@@ -58,6 +59,9 @@ func (self *ModeHelper) Statuses() []ModeStatus {
|
||||
style.FgMagenta,
|
||||
)
|
||||
},
|
||||
CancelLabel: func() string {
|
||||
return self.c.Tr.CancelDiffingMode
|
||||
},
|
||||
Reset: self.diffHelper.ExitDiffMode,
|
||||
},
|
||||
{
|
||||
@@ -65,6 +69,9 @@ func (self *ModeHelper) Statuses() []ModeStatus {
|
||||
InfoLabel: func() string {
|
||||
return self.withResetButton(self.c.Tr.BuildingPatch, style.FgYellow.SetBold())
|
||||
},
|
||||
CancelLabel: func() string {
|
||||
return self.c.Tr.ExitCustomPatchBuilder
|
||||
},
|
||||
Reset: self.patchBuildingHelper.Reset,
|
||||
},
|
||||
{
|
||||
@@ -80,6 +87,9 @@ func (self *ModeHelper) Statuses() []ModeStatus {
|
||||
style.FgRed,
|
||||
)
|
||||
},
|
||||
CancelLabel: func() string {
|
||||
return self.c.Tr.ExitFilterMode
|
||||
},
|
||||
Reset: self.ExitFilterMode,
|
||||
},
|
||||
{
|
||||
@@ -90,6 +100,9 @@ func (self *ModeHelper) Statuses() []ModeStatus {
|
||||
style.FgCyan,
|
||||
)
|
||||
},
|
||||
CancelLabel: func() string {
|
||||
return self.c.Tr.CancelMarkedBaseCommit
|
||||
},
|
||||
Reset: self.mergeAndRebaseHelper.ResetMarkedBaseCommit,
|
||||
},
|
||||
{
|
||||
@@ -110,6 +123,9 @@ func (self *ModeHelper) Statuses() []ModeStatus {
|
||||
style.FgCyan,
|
||||
)
|
||||
},
|
||||
CancelLabel: func() string {
|
||||
return self.c.Tr.ResetCherryPickShort
|
||||
},
|
||||
Reset: self.cherryPickHelper.Reset,
|
||||
},
|
||||
{
|
||||
@@ -122,6 +138,9 @@ func (self *ModeHelper) Statuses() []ModeStatus {
|
||||
workingTreeState.Title(self.c.Tr), style.FgYellow,
|
||||
)
|
||||
},
|
||||
CancelLabel: func() string {
|
||||
return fmt.Sprintf(self.c.Tr.AbortTitle, self.c.Git().Status.WorkingTreeState().CommandName())
|
||||
},
|
||||
Reset: self.mergeAndRebaseHelper.AbortMergeOrRebaseWithConfirm,
|
||||
},
|
||||
{
|
||||
@@ -131,6 +150,9 @@ func (self *ModeHelper) Statuses() []ModeStatus {
|
||||
InfoLabel: func() string {
|
||||
return self.withResetButton(self.c.Tr.Bisect.Bisecting, style.FgGreen)
|
||||
},
|
||||
CancelLabel: func() string {
|
||||
return self.c.Tr.Actions.ResetBisect
|
||||
},
|
||||
Reset: self.bisectHelper.Reset,
|
||||
},
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ func (self *QuitActions) confirmQuitDuringUpdate() error {
|
||||
}
|
||||
|
||||
func (self *QuitActions) Escape() error {
|
||||
// If you make changes to this function, be sure to update EscapeEnabled accordingly.
|
||||
// If you make changes to this function, be sure to update EscapeEnabled and EscapeDescription accordingly.
|
||||
|
||||
currentContext := self.c.Context().Current()
|
||||
|
||||
@@ -130,3 +130,41 @@ func (self *QuitActions) EscapeEnabled() bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *QuitActions) EscapeDescription() string {
|
||||
currentContext := self.c.Context().Current()
|
||||
|
||||
if listContext, ok := currentContext.(types.IListContext); ok {
|
||||
if listContext.GetList().IsSelectingRange() {
|
||||
return self.c.Tr.DismissRangeSelect
|
||||
}
|
||||
}
|
||||
|
||||
if ctx, ok := currentContext.(types.IFilterableContext); ok {
|
||||
if ctx.IsFiltering() {
|
||||
return self.c.Tr.ExitFilterMode
|
||||
}
|
||||
}
|
||||
|
||||
parentContext := currentContext.GetParentContext()
|
||||
if parentContext != nil {
|
||||
return self.c.Tr.ExitSubview
|
||||
}
|
||||
|
||||
for _, mode := range self.c.Helpers().Mode.Statuses() {
|
||||
if mode.IsActive() {
|
||||
return mode.CancelLabel()
|
||||
}
|
||||
}
|
||||
|
||||
repoPathStack := self.c.State().GetRepoPathStack()
|
||||
if !repoPathStack.IsEmpty() {
|
||||
return self.c.Tr.BackToParentRepo
|
||||
}
|
||||
|
||||
if self.c.UserConfig().QuitOnTopLevelReturn {
|
||||
return self.c.Tr.Quit
|
||||
}
|
||||
|
||||
return self.c.Tr.Cancel
|
||||
}
|
||||
|
@@ -601,6 +601,7 @@ type TranslationSet struct {
|
||||
RenameBranchWarning string
|
||||
OpenKeybindingsMenu string
|
||||
ResetCherryPick string
|
||||
ResetCherryPickShort string
|
||||
NextTab string
|
||||
PrevTab string
|
||||
CantUndoWhileRebasing string
|
||||
@@ -634,6 +635,7 @@ type TranslationSet struct {
|
||||
SwapDiff string
|
||||
ViewDiffingOptions string
|
||||
ViewDiffingOptionsTooltip string
|
||||
CancelDiffingMode string
|
||||
OpenCommandLogMenu string
|
||||
OpenCommandLogMenuTooltip string
|
||||
ShowingGitDiff string
|
||||
@@ -671,6 +673,7 @@ type TranslationSet struct {
|
||||
SubmoduleStashAndReset string
|
||||
AndResetSubmodules string
|
||||
EnterSubmoduleTooltip string
|
||||
BackToParentRepo string
|
||||
Enter string
|
||||
CopySubmoduleNameToClipboard string
|
||||
RemoveSubmodule string
|
||||
@@ -699,6 +702,7 @@ type TranslationSet struct {
|
||||
BulkSubmoduleOptions string
|
||||
RunningCommand string
|
||||
SubCommitsTitle string
|
||||
ExitSubview string
|
||||
SubmodulesTitle string
|
||||
NavigationTitle string
|
||||
SuggestionsCheatsheetTitle string
|
||||
@@ -861,6 +865,7 @@ type TranslationSet struct {
|
||||
MarkedBaseCommitStatus string
|
||||
MarkAsBaseCommit string
|
||||
MarkAsBaseCommitTooltip string
|
||||
CancelMarkedBaseCommit string
|
||||
MarkedCommitMarker string
|
||||
FailedToOpenURL string
|
||||
InvalidLazygitEditURL string
|
||||
@@ -870,6 +875,7 @@ type TranslationSet struct {
|
||||
QuickStartInteractiveRebaseTooltip string
|
||||
CannotQuickStartInteractiveRebase string
|
||||
ToggleRangeSelect string
|
||||
DismissRangeSelect string
|
||||
RangeSelectUp string
|
||||
RangeSelectDown string
|
||||
RangeSelectNotSupported string
|
||||
@@ -1349,6 +1355,7 @@ func EnglishTranslationSet() *TranslationSet {
|
||||
DiscardSelection: `Discard`,
|
||||
DiscardSelectionTooltip: "When unstaged change is selected, discard the change using `git reset`. When staged change is selected, unstage the change.",
|
||||
ToggleRangeSelect: "Toggle range select",
|
||||
DismissRangeSelect: "Dismiss range select",
|
||||
ToggleSelectHunk: "Toggle hunk selection",
|
||||
SelectHunk: "Select hunks",
|
||||
SelectLineByLine: "Select line-by-line",
|
||||
@@ -1667,6 +1674,7 @@ func EnglishTranslationSet() *TranslationSet {
|
||||
RenameBranchWarning: "This branch is tracking a remote. This action will only rename the local branch name, not the name of the remote branch. Continue?",
|
||||
OpenKeybindingsMenu: "Open keybindings menu",
|
||||
ResetCherryPick: "Reset copied (cherry-picked) commits selection",
|
||||
ResetCherryPickShort: "Reset copied commits",
|
||||
NextTab: "Next tab",
|
||||
PrevTab: "Previous tab",
|
||||
CantUndoWhileRebasing: "Can't undo while rebasing",
|
||||
@@ -1700,6 +1708,7 @@ func EnglishTranslationSet() *TranslationSet {
|
||||
SwapDiff: "Reverse diff direction",
|
||||
ViewDiffingOptions: "View diffing options",
|
||||
ViewDiffingOptionsTooltip: "View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction.",
|
||||
CancelDiffingMode: "Cancel diffing mode",
|
||||
// the actual view is the extras view which I intend to give more tabs in future but for now we'll only mention the command log part
|
||||
OpenCommandLogMenu: "View command log options",
|
||||
OpenCommandLogMenuTooltip: "View options for the command log e.g. show/hide the command log and focus the command log.",
|
||||
@@ -1739,6 +1748,7 @@ func EnglishTranslationSet() *TranslationSet {
|
||||
AndResetSubmodules: "And reset submodules",
|
||||
Enter: "Enter",
|
||||
EnterSubmoduleTooltip: "Enter submodule. After entering the submodule, you can press `{{.escape}}` to escape back to the parent repo.",
|
||||
BackToParentRepo: "Back to parent repo",
|
||||
CopySubmoduleNameToClipboard: "Copy submodule name to clipboard",
|
||||
RemoveSubmodule: "Remove submodule",
|
||||
RemoveSubmodulePrompt: "Are you sure you want to remove submodule '%s' and its corresponding directory? This is irreversible.",
|
||||
@@ -1766,6 +1776,7 @@ func EnglishTranslationSet() *TranslationSet {
|
||||
BulkSubmoduleOptions: "Bulk submodule options",
|
||||
RunningCommand: "Running command",
|
||||
SubCommitsTitle: "Sub-commits",
|
||||
ExitSubview: "Exit subview",
|
||||
SubmodulesTitle: "Submodules",
|
||||
NavigationTitle: "List panel navigation",
|
||||
SuggestionsCheatsheetTitle: "Suggestions",
|
||||
@@ -1925,6 +1936,7 @@ func EnglishTranslationSet() *TranslationSet {
|
||||
MarkedBaseCommitStatus: "Marked a base commit for rebase",
|
||||
MarkAsBaseCommit: "Mark as base commit for rebase",
|
||||
MarkAsBaseCommitTooltip: "Select a base commit for the next rebase. When you rebase onto a branch, only commits above the base commit will be brought across. This uses the `git rebase --onto` command.",
|
||||
CancelMarkedBaseCommit: "Cancel marked base commit",
|
||||
MarkedCommitMarker: "↑↑↑ Will rebase from here ↑↑↑",
|
||||
FailedToOpenURL: "Failed to open URL %s\n\nError: %v",
|
||||
InvalidLazygitEditURL: "Invalid lazygit-edit URL format: %s",
|
||||
|
Reference in New Issue
Block a user