From b385a4e164ee585135c89184db33a5f5c0d66bd4 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 11 Nov 2026 09:13:48 +0100 Subject: [PATCH] Add "Clear commit message" to the commit menu Many users don't know that they can clear the commit message panel quickly by holding down ctrl+u. They hold down backspace instead, and for a long message this takes a long time. Co-Authored-By: Claude Opus 5.5 --- pkg/gui/controllers/helpers/commits_helper.go | 8 ++++ pkg/i18n/english.go | 2 + .../tests/commit/clear_commit_message.go | 39 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 4 files changed, 50 insertions(+) create mode 100644 pkg/integration/tests/commit/clear_commit_message.go diff --git a/pkg/gui/controllers/helpers/commits_helper.go b/pkg/gui/controllers/helpers/commits_helper.go index 601fc45a9..3d58e6aec 100644 --- a/pkg/gui/controllers/helpers/commits_helper.go +++ b/pkg/gui/controllers/helpers/commits_helper.go @@ -263,6 +263,14 @@ func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.S }, Keys: menuKey('V'), }, + { + Label: self.c.Tr.ClearCommitMessage, + OnPress: func() error { + self.setSummaryAndDescriptionInView("", "") + return nil + }, + Keys: menuKey('d'), + }, } return self.c.Menu(types.CreateMenuOptions{ Title: self.c.Tr.CommitMenuTitle, diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index d923c6e3b..d8aad8b99 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -768,6 +768,7 @@ type TranslationSet struct { CopyCommitMessageToClipboard string PasteCommitMessageFromClipboard string SurePasteCommitMessage string + ClearCommitMessage string CommitMessage string CommitMessageBody string CommitSubject string @@ -2006,6 +2007,7 @@ func EnglishTranslationSet() *TranslationSet { CopyCommitMessageToClipboard: "Copy commit message to clipboard", PasteCommitMessageFromClipboard: "Paste commit message from clipboard", SurePasteCommitMessage: "Pasting will overwrite the current commit message, continue?", + ClearCommitMessage: "Clear commit message", CommitMessage: "Commit message (subject and body)", CommitMessageBody: "Commit message body", CommitSubject: "Commit subject", diff --git a/pkg/integration/tests/commit/clear_commit_message.go b/pkg/integration/tests/commit/clear_commit_message.go new file mode 100644 index 000000000..1c5909357 --- /dev/null +++ b/pkg/integration/tests/commit/clear_commit_message.go @@ -0,0 +1,39 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var ClearCommitMessage = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Clear the commit message in the commit message panel", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFileAndAdd("file", "file content") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Files(). + Focus(). + Press(keys.Files.CommitChanges) + + t.ExpectPopup().CommitMessagePanel(). + Type("subject"). + SwitchToDescription(). + Type("first line"). + AddNewline(). + Type("second line"). + SwitchToSummary(). + OpenCommitMenu() + + t.ExpectPopup().Menu().Title(Equals("Commit Menu")). + Select(Contains("Clear commit message")). + Confirm() + + t.ExpectPopup().CommitMessagePanel(). + Content(Equals("")). + SwitchToDescription(). + Content(Equals("")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 6c8e83b6a..c6ee9564f 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -142,6 +142,7 @@ var tests = []*components.IntegrationTest{ commit.CheckoutFileFromCommit, commit.CheckoutFileFromRangeSelectionOfCommits, commit.CheckoutFileWithLocalModifications, + commit.ClearCommitMessage, commit.Commit, commit.CommitAllWithNestedRepository, commit.CommitDuringSquashMerge,