From 07a5bb58673b672eb325ba2b25b0b25d13fa6aef Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 19 Apr 2026 12:08:24 +0200 Subject: [PATCH] Add integration test demonstrating whitespace loss in preserved commit messages Typing a description with leading blank lines, canceling the commit panel, and reopening it currently drops leading blank lines. --- .../preserve_commit_message_whitespace.go | 42 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 43 insertions(+) create mode 100644 pkg/integration/tests/commit/preserve_commit_message_whitespace.go diff --git a/pkg/integration/tests/commit/preserve_commit_message_whitespace.go b/pkg/integration/tests/commit/preserve_commit_message_whitespace.go new file mode 100644 index 000000000..78ddda196 --- /dev/null +++ b/pkg/integration/tests/commit/preserve_commit_message_whitespace.go @@ -0,0 +1,42 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var PreserveCommitMessageWhitespace = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Whitespace in the description (e.g. leading blank lines, indented first line) should be preserved when canceling and reopening the commit message panel", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFileAndAdd("myfile", "myfile content") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Files(). + IsFocused(). + Press(keys.Files.CommitChanges) + + t.ExpectPopup().CommitMessagePanel(). + Type("my commit message"). + SwitchToDescription(). + AddNewline(). + AddNewline(). + Type("body "). + Cancel() + + t.Views().Files(). + IsFocused(). + Press(keys.Files.CommitChanges) + + t.ExpectPopup().CommitMessagePanel(). + Content(Equals("my commit message")). + SwitchToDescription(). + /* EXPECTED: + Content(Equals("\n\nbody ")). + ACTUAL: */ + Content(Equals("body")). + Cancel() + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 04c12e600..09d487852 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -142,6 +142,7 @@ var tests = []*components.IntegrationTest{ commit.PasteCommitMessage, commit.PasteCommitMessageOverExisting, commit.PreserveCommitMessage, + commit.PreserveCommitMessageWhitespace, commit.ResetAuthor, commit.ResetAuthorRange, commit.Revert,