mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-12 15:53:33 -04:00
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8b8e3c05aa
commit
1c7ccd5833
@@ -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."))
|
||||
},
|
||||
})
|
||||
@@ -185,6 +185,7 @@ var tests = []*components.IntegrationTest{
|
||||
commit.NewBranch,
|
||||
commit.PasteCommitMessage,
|
||||
commit.PasteCommitMessageOverExisting,
|
||||
commit.PasteCommitMessageWithHardLineBreaks,
|
||||
commit.PreserveCommitMessage,
|
||||
commit.PreserveCommitMessageWhitespace,
|
||||
commit.ResetAuthor,
|
||||
|
||||
Reference in New Issue
Block a user