diff --git a/pkg/gui/controllers/helpers/commits_helper.go b/pkg/gui/controllers/helpers/commits_helper.go index adbb98f52..3a273b532 100644 --- a/pkg/gui/controllers/helpers/commits_helper.go +++ b/pkg/gui/controllers/helpers/commits_helper.go @@ -346,7 +346,11 @@ func (self *CommitsHelper) HandlePasteIntoDescription(text string) { // pastes a whole commit message into the summary text = strings.TrimLeft(text, "\n") } - view.TextArea.TypeString(replaceTabsInPastedText(text)) + // Remove the hard line breaks of the pasted text on its own, even if it + // goes into the middle of a line. Its line breaks come from the layout of + // the text that it was copied from, not from the line that it goes into. + text = self.TryRemoveHardLineBreaksIfAutoWrapping(replaceTabsInPastedText(text)) + view.TextArea.TypeString(text) view.RenderTextArea() } diff --git a/pkg/integration/tests/commit/paste_multi_line_commit_message_with_hard_line_breaks.go b/pkg/integration/tests/commit/paste_multi_line_commit_message_with_hard_line_breaks.go index 1c566cb7c..99890ce27 100644 --- a/pkg/integration/tests/commit/paste_multi_line_commit_message_with_hard_line_breaks.go +++ b/pkg/integration/tests/commit/paste_multi_line_commit_message_with_hard_line_breaks.go @@ -28,12 +28,7 @@ var PasteMultiLineCommitMessageWithHardLineBreaks = NewIntegrationTest(NewIntegr 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.")) }, })