diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 4c2ee1090b4e369bbd6a2f5a02a6ce48ba401f60..98d427479224f7b634ec4ae7f5dd7b369d5a40b1 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -3953,6 +3953,7 @@ void BaseTextEditor::rewrapParagraph()
 
                 if (currentLength > paragraphWidth) {
                     currentLength = currentWord.length() + 1 + indentLevel;
+                    result.chop(1); // remove trailing space
                     result.append(QChar::ParagraphSeparator);
                     result.append(spacing);
                 }
@@ -3967,6 +3968,7 @@ void BaseTextEditor::rewrapParagraph()
 
         currentWord.append(ch);
     }
+    result.chop(1);
     result.append(QChar::ParagraphSeparator);
 
     cursor.insertText(result);