1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-05-21 22:43:27 +02:00

Disabled paste when there are no copied commits

This commit is contained in:
Stefan Haller 2023-09-15 17:46:21 +02:00
parent 8b6766de79
commit 0b13c3ca87
3 changed files with 18 additions and 3 deletions

View File

@ -85,6 +85,10 @@ func (self *CherryPickHelper) Paste() error {
}) })
} }
func (self *CherryPickHelper) CanPaste() bool {
return self.getData().Active()
}
func (self *CherryPickHelper) Reset() error { func (self *CherryPickHelper) Reset() error {
self.getData().ContextKey = "" self.getData().ContextKey = ""
self.getData().CherryPickedCommits = nil self.getData().CherryPickedCommits = nil

View File

@ -112,6 +112,7 @@ func (self *LocalCommitsController) GetKeybindings(opts types.KeybindingsOpts) [
{ {
Key: opts.GetKey(opts.Config.Commits.PasteCommits), Key: opts.GetKey(opts.Config.Commits.PasteCommits),
Handler: self.paste, Handler: self.paste,
GetDisabledReason: self.getDisabledReasonForPaste,
Description: self.c.Tr.PasteCommits, Description: self.c.Tr.PasteCommits,
}, },
{ {
@ -1001,6 +1002,14 @@ func (self *LocalCommitsController) paste() error {
return self.c.Helpers().CherryPick.Paste() return self.c.Helpers().CherryPick.Paste()
} }
func (self *LocalCommitsController) getDisabledReasonForPaste() string {
if !self.c.Helpers().CherryPick.CanPaste() {
return self.c.Tr.NoCopiedCommits
}
return ""
}
func (self *LocalCommitsController) markAsBaseCommit(commit *models.Commit) error { func (self *LocalCommitsController) markAsBaseCommit(commit *models.Commit) error {
if commit.Sha == self.c.Modes().MarkedBaseCommit.GetSha() { if commit.Sha == self.c.Modes().MarkedBaseCommit.GetSha() {
// Reset when invoking it again on the marked commit // Reset when invoking it again on the marked commit

View File

@ -612,6 +612,7 @@ type TranslationSet struct {
PleaseGoToURL string PleaseGoToURL string
DisabledMenuItemPrefix string DisabledMenuItemPrefix string
NoCommitSelected string NoCommitSelected string
NoCopiedCommits string
Actions Actions Actions Actions
Bisect Bisect Bisect Bisect
Log Log Log Log
@ -1403,6 +1404,7 @@ func EnglishTranslationSet() TranslationSet {
PleaseGoToURL: "Please go to {{.url}}", PleaseGoToURL: "Please go to {{.url}}",
DisabledMenuItemPrefix: "Disabled: ", DisabledMenuItemPrefix: "Disabled: ",
NoCommitSelected: "No commit selected", NoCommitSelected: "No commit selected",
NoCopiedCommits: "No copied commits",
Actions: Actions{ Actions: Actions{
// TODO: combine this with the original keybinding descriptions (those are all in lowercase atm) // TODO: combine this with the original keybinding descriptions (those are all in lowercase atm)
CheckoutCommit: "Checkout commit", CheckoutCommit: "Checkout commit",