diff --git a/src/libs/qmljs/qmljsrewriter.cpp b/src/libs/qmljs/qmljsrewriter.cpp index 22e142127102f0b482b8b4a75e62e202b3fd9515..093f671c66f403289f34f711760b6979165c5470 100644 --- a/src/libs/qmljs/qmljsrewriter.cpp +++ b/src/libs/qmljs/qmljsrewriter.cpp @@ -419,8 +419,6 @@ bool Rewriter::includeSurroundingWhitespace(int &start, int &end) const while (c.isSpace()) { ++end; - - if (c.unicode() == 10) { paragraphFound = true; break; @@ -434,18 +432,23 @@ bool Rewriter::includeSurroundingWhitespace(int &start, int &end) const includeStartingWhitespace = paragraphFound; } + paragraphFound = false; if (includeStartingWhitespace) { while (start > 0) { const QChar c = m_originalText.at(start - 1); - if (!c.isSpace()) + if (c.unicode() == 10) { + paragraphFound = true; break; - else if (c.unicode() == 10) + } + if (!c.isSpace()) break; --start; } } + if (!paragraphFound) //keep the line ending + --end; return paragraphFound; }