aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2020-06-12 15:24:25 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2020-07-02 13:30:42 +0200
commit6b72b1a6861ddc10356c5505a00e2204fdfe83e5 (patch)
treea8ca699ff0aff888516099f03a040c61651a1d2a /tools
parent9ac953aefdec4481d53cea61b494d6657a61d03e (diff)
qmlformat: Fix trailing newline in if blocks
Fixes: QTBUG-85003 Change-Id: Ie68c838c9bc1d52181a741871279bee5a8020855 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 15777b94ee96035be79b363f3b1e54f02b5d2cd5)
Diffstat (limited to 'tools')
-rw-r--r--tools/qmlformat/dumpastvisitor.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/qmlformat/dumpastvisitor.cpp b/tools/qmlformat/dumpastvisitor.cpp
index 3ad66bc6a1..9f49fe0090 100644
--- a/tools/qmlformat/dumpastvisitor.cpp
+++ b/tools/qmlformat/dumpastvisitor.cpp
@@ -692,6 +692,10 @@ QString DumpAstVisitor::parseStatement(Statement *statement, bool blockHasNext,
result += formatLine("else", false);
if (ifFalseBlock) {
+ // Blocks generate an extra newline that we don't want here.
+ if (!m_blockNeededBraces && ifFalse.endsWith(QLatin1String("\n")))
+ ifFalse.chop(1);
+
result += " " + ifFalse;
} else {
result += "\n";