diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2020-06-12 15:24:25 +0200 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2020-06-17 13:04:42 +0200 |
commit | 15777b94ee96035be79b363f3b1e54f02b5d2cd5 (patch) | |
tree | fb548bf756479b5a463c80fba7c5fa92cded2244 /tools/qmlformat | |
parent | 237a0e86c700116bfa55a1e1ee6fdabcc1ca5c9c (diff) |
qmlformat: Fix trailing newline in if blocks
Fixes: QTBUG-85003
Change-Id: Ie68c838c9bc1d52181a741871279bee5a8020855
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/qmlformat')
-rw-r--r-- | tools/qmlformat/dumpastvisitor.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/qmlformat/dumpastvisitor.cpp b/tools/qmlformat/dumpastvisitor.cpp index af6722be39..ad310ead3d 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"; |