Skip to content
Snippets Groups Projects
Commit 3b48da93 authored by Kai Koehne's avatar Kai Koehne
Browse files

QmlJs: Fix corner case in Rewriter (whitespace handling)

Done by erikv
parent 17431b40
No related branches found
No related tags found
No related merge requests found
...@@ -413,6 +413,7 @@ bool Rewriter::includeSurroundingWhitespace(const QString &source, int &start, i ...@@ -413,6 +413,7 @@ bool Rewriter::includeSurroundingWhitespace(const QString &source, int &start, i
{ {
bool includeStartingWhitespace = true; bool includeStartingWhitespace = true;
bool paragraphFound = false; bool paragraphFound = false;
bool paragraphSkipped = false;
if (end >= 0) { if (end >= 0) {
QChar c = source.at(end); QChar c = source.at(end);
...@@ -421,6 +422,7 @@ bool Rewriter::includeSurroundingWhitespace(const QString &source, int &start, i ...@@ -421,6 +422,7 @@ bool Rewriter::includeSurroundingWhitespace(const QString &source, int &start, i
++end; ++end;
if (c.unicode() == 10) { if (c.unicode() == 10) {
paragraphFound = true; paragraphFound = true;
paragraphSkipped = true;
break; break;
} else if (end == source.length()) { } else if (end == source.length()) {
break; break;
...@@ -447,7 +449,7 @@ bool Rewriter::includeSurroundingWhitespace(const QString &source, int &start, i ...@@ -447,7 +449,7 @@ bool Rewriter::includeSurroundingWhitespace(const QString &source, int &start, i
--start; --start;
} }
} }
if (!paragraphFound) //keep the line ending if (!paragraphFound && paragraphSkipped) //keep the line ending
--end; --end;
return paragraphFound; return paragraphFound;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment