Skip to content

Commit

Permalink
qmljsreformatter: don't default foreach type to "in"
Browse files Browse the repository at this point in the history
Fixes: QTCREATORBUG-29123
Change-Id: I4d3a611c359946c4483388cbf18a0b6f16d0a8d6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
  • Loading branch information
Semih Yavuz committed May 8, 2023
1 parent a65637b commit cd73f8c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libs/qmljs/qmljsreformatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,10 @@ class Rewriter : protected Visitor
out(" ");
out(ast->lparenToken);
accept(ast->lhs);
out(" in ");
if (ast->type == ForEachType::In)
out(" in ");
else
out(" of ");
accept(ast->expression);
out(ast->rparenToken);
acceptBlockOrIndented(ast->statement);
Expand Down
9 changes: 9 additions & 0 deletions tests/auto/qml/reformatter/forEachType.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import QtQml

QtObject {
Component.onCompleted: {
for (var i of ["one", "two", "free"]) {
console.debug(i)
}
}
}

0 comments on commit cd73f8c

Please sign in to comment.