diff options
| author | Semih Yavuz <semih.yavuz@qt.io> | 2023-05-05 19:44:56 +0200 |
|---|---|---|
| committer | Semih Yavuz <semih.yavuz@qt.io> | 2023-05-08 07:39:26 +0000 |
| commit | cd73f8c6b8dd6e62b3cdff972d7194f4ff34a105 (patch) | |
| tree | eb1f9dde2949aedd2aed3e45d6ed823a2eff5f7f | |
| parent | a65637be5ca94c10fb053e301463af2f7313a358 (diff) | |
| download | qt-creator-cd73f8c6b8dd6e62b3cdff972d7194f4ff34a105.tar.gz | |
qmljsreformatter: don't default foreach type to "in"
Fixes: QTCREATORBUG-29123
Change-Id: I4d3a611c359946c4483388cbf18a0b6f16d0a8d6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
| -rw-r--r-- | src/libs/qmljs/qmljsreformatter.cpp | 5 | ||||
| -rw-r--r-- | tests/auto/qml/reformatter/forEachType.qml | 9 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/libs/qmljs/qmljsreformatter.cpp b/src/libs/qmljs/qmljsreformatter.cpp index 03a95a668c..232c0361a1 100644 --- a/src/libs/qmljs/qmljsreformatter.cpp +++ b/src/libs/qmljs/qmljsreformatter.cpp @@ -1088,7 +1088,10 @@ protected: 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); diff --git a/tests/auto/qml/reformatter/forEachType.qml b/tests/auto/qml/reformatter/forEachType.qml new file mode 100644 index 0000000000..6fdabbde1b --- /dev/null +++ b/tests/auto/qml/reformatter/forEachType.qml @@ -0,0 +1,9 @@ +import QtQml + +QtObject { + Component.onCompleted: { + for (var i of ["one", "two", "free"]) { + console.debug(i) + } + } +} |
