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

Warn users when attempting to cherry pick with old key

I wrote this feature and even I sometimes use the wrong key so I want
to make this very clear to users so that there's no confusion
This commit is contained in:
Jesse Duffield
2024-01-28 11:46:20 +11:00
parent cf5d4d4f8e
commit e1aa68a7bd
2 changed files with 21 additions and 0 deletions

View File

@ -106,6 +106,14 @@ func (self *BasicCommitsController) GetKeybindings(opts types.KeybindingsOpts) [
GetDisabledReason: self.require(self.singleItemSelected()),
Description: self.c.Tr.OpenDiffTool,
},
// Putting this at the bottom of the list so that it has the lowest priority,
// meaning that if the user has configured another keybinding to the same key
// then that will take precedence.
{
// Hardcoding this key because it's not configurable
Key: opts.GetKey("c"),
Handler: self.handleOldCherryPickKey,
},
}
return bindings
@ -284,6 +292,16 @@ func (self *BasicCommitsController) copyRange(*models.Commit) error {
return self.c.Helpers().CherryPick.CopyRange(self.context.GetCommits(), self.context)
}
func (self *BasicCommitsController) handleOldCherryPickKey() error {
msg := utils.ResolvePlaceholderString(self.c.Tr.OldCherryPickKeyWarning,
map[string]string{
"copy": keybindings.Label(self.c.UserConfig.Keybinding.Commits.CherryPickCopy),
"paste": keybindings.Label(self.c.UserConfig.Keybinding.Commits.PasteCommits),
})
return self.c.ErrorMsg(msg)
}
func (self *BasicCommitsController) openDiffTool(commit *models.Commit) error {
to := commit.RefName()
from, reverse := self.c.Modes().Diffing.GetFromAndReverseArgsForDiff(commit.ParentRefName())