From 1c7ccd58334bcace0bd97f3710182135d0a5ceeb Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 11 Nov 2026 10:22:47 +0100 Subject: [PATCH] Add a test for pasting a commit message that has hard line breaks If you copy a commit's message with `y` in the commits panel and paste it into the commit message panel with the commit menu, the body keeps the hard line breaks that git committed. This happens even where auto-wrapping would break the line at the same place. If you then edit a paragraph of the body, it doesn't reflow. Co-Authored-By: Claude Opus 5.5 --- ...te_commit_message_with_hard_line_breaks.go | 57 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 58 insertions(+) create mode 100644 pkg/integration/tests/commit/paste_commit_message_with_hard_line_breaks.go diff --git a/pkg/integration/tests/commit/paste_commit_message_with_hard_line_breaks.go b/pkg/integration/tests/commit/paste_commit_message_with_hard_line_breaks.go new file mode 100644 index 000000000..2fa53d3f4 --- /dev/null +++ b/pkg/integration/tests/commit/paste_commit_message_with_hard_line_breaks.go @@ -0,0 +1,57 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var PasteCommitMessageWithHardLineBreaks = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Paste a commit message whose body was wrapped at the auto-wrap width, and check that the body reflows when editing it", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) { + config.GetUserConfig().OS.CopyToClipboardCmd = "printf '%s' {{text}} > ../clipboard" + config.GetUserConfig().OS.ReadFromClipboardCmd = "cat ../clipboard" + }, + SetupRepo: func(shell *Shell) { + shell.EmptyCommit("subject\n\n" + + "The body of this commit was wrapped at the auto-wrap width when it was\n" + + "committed, so it contains a hard line break.") + shell.CreateFileAndAdd("file", "file content") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Press(keys.Commits.CopyCommitAttributeToClipboard) + + t.ExpectPopup().Menu().Title(Equals("Copy to clipboard")). + Select(Contains("Commit message (subject and body)")).Confirm() + + t.ExpectToast(Equals("Commit message copied to clipboard")) + + t.Views().Files(). + Focus(). + Press(keys.Files.CommitChanges) + + t.ExpectPopup().CommitMessagePanel(). + OpenCommitMenu() + + t.ExpectPopup().Menu().Title(Equals("Commit Menu")). + Select(Contains("Paste commit message from clipboard")). + Confirm() + + t.ExpectPopup().CommitMessagePanel(). + Content(Equals("subject")). + SwitchToDescription(). + GoToBeginning(). + Type("Now "). + Content(Equals( + /* EXPECTED: + "Now The body of this commit was wrapped at the auto-wrap width when it \n" + + "was committed, so it contains a hard line break.")) + ACTUAL: */ + "Now The body of this commit was wrapped at the auto-wrap width when it \n" + + "was\n" + + "committed, so it contains a hard line break.")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index c6ee9564f..26edb3c13 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -185,6 +185,7 @@ var tests = []*components.IntegrationTest{ commit.NewBranch, commit.PasteCommitMessage, commit.PasteCommitMessageOverExisting, + commit.PasteCommitMessageWithHardLineBreaks, commit.PreserveCommitMessage, commit.PreserveCommitMessageWhitespace, commit.ResetAuthor,