From ca825d2a961b5f065e83b73baae22a2cae03ec51 Mon Sep 17 00:00:00 2001
From: Henrik Abelsson <henrik@abelsson.com>
Date: Tue, 21 Jul 2009 12:34:56 +0200
Subject: [PATCH] Fixed the rewrapping not to leave around trailing spaces
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reviewed-by: Thorbjørn Lindeijer
---
 src/plugins/texteditor/basetexteditor.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 4c2ee1090b4..98d42747922 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);
-- 
GitLab