mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-23 12:18:51 +02:00
Fix disabling the switch-to-editor menu item if unavailable
Some operations don't support switching to the editor from the commit message panel; an example is the commit message panel that appears when moving a custom patch into a new commit. Disable the "open in editor" menu entry in this case, instead of silently doing nothing.
This commit is contained in:
parent
1a9ce9db94
commit
7764e6d1cb
@ -91,10 +91,6 @@ func TryRemoveHardLineBreaks(message string, autoWrapWidth int) string {
|
||||
}
|
||||
|
||||
func (self *CommitsHelper) SwitchToEditor() error {
|
||||
if !self.c.Contexts().CommitMessage.CanSwitchToEditor() {
|
||||
return nil
|
||||
}
|
||||
|
||||
message := lo.Ternary(len(self.getCommitDescription()) == 0,
|
||||
self.getCommitSummary(),
|
||||
self.getCommitSummary()+"\n\n"+self.getCommitDescription())
|
||||
@ -218,6 +214,13 @@ func (self *CommitsHelper) commitMessageContexts() []types.Context {
|
||||
}
|
||||
|
||||
func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.Suggestion) error {
|
||||
var disabledReasonForOpenInEditor *types.DisabledReason
|
||||
if !self.c.Contexts().CommitMessage.CanSwitchToEditor() {
|
||||
disabledReasonForOpenInEditor = &types.DisabledReason{
|
||||
Text: self.c.Tr.CommandDoesNotSupportOpeningInEditor,
|
||||
}
|
||||
}
|
||||
|
||||
menuItems := []*types.MenuItem{
|
||||
{
|
||||
Label: self.c.Tr.OpenInEditor,
|
||||
@ -225,6 +228,7 @@ func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.S
|
||||
return self.SwitchToEditor()
|
||||
},
|
||||
Key: 'e',
|
||||
DisabledReason: disabledReasonForOpenInEditor,
|
||||
},
|
||||
{
|
||||
Label: self.c.Tr.AddCoAuthor,
|
||||
|
@ -775,6 +775,7 @@ type TranslationSet struct {
|
||||
SelectedItemDoesNotHaveFiles string
|
||||
RangeSelectNotSupportedForSubmodules string
|
||||
OldCherryPickKeyWarning string
|
||||
CommandDoesNotSupportOpeningInEditor string
|
||||
Actions Actions
|
||||
Bisect Bisect
|
||||
Log Log
|
||||
@ -1731,6 +1732,7 @@ func EnglishTranslationSet() TranslationSet {
|
||||
SelectedItemDoesNotHaveFiles: "Selected item does not have files to view",
|
||||
RangeSelectNotSupportedForSubmodules: "Range select not supported for submodules",
|
||||
OldCherryPickKeyWarning: "The 'c' key is no longer the default key for copying commits to cherry pick. Please use `{{.copy}}` instead (and `{{.paste}}` to paste). The reason for this change is that the 'v' key for selecting a range of lines when staging is now also used for selecting a range of lines in any list view, meaning that we needed to find a new key for pasting commits, and if we're going to now use `{{.paste}}` for pasting commits, we may as well use `{{.copy}}` for copying them. If you want to configure the keybindings to get the old behaviour, set the following in your config:\n\nkeybinding:\n universal:\n toggleRangeSelect: <something other than v>\n commits:\n cherryPickCopy: 'c'\n pasteCommits: 'v'",
|
||||
CommandDoesNotSupportOpeningInEditor: "This command doesn't support switching to the editor",
|
||||
|
||||
Actions: Actions{
|
||||
// TODO: combine this with the original keybinding descriptions (those are all in lowercase atm)
|
||||
|
Loading…
x
Reference in New Issue
Block a user