Details
-
Bug
-
Resolution: Done
-
P2: Important
-
Qt Creator 4.9.0
-
-
3d21c7fdc3b70a7c0dfecec8b88beb99d03c517e
Description
QtCreator's auto-formatting function for QML/JS code (Tools -> QML/JS -> Reformat File) breaks JavaScript code, whether embedded in QML files or in a separate JavaScript file. This happens on Linux and Windows with the QtCreator version from the official installer.
4 errors occur since at least version 4.8, up to the most recent 4.9:
- Function arguments are "merged" into one word, i.e. commas and spaces between them removed.
- Variables declared in for-loops are removed.
- In pure JavaScript files, the ".pragma library" directive is removed.
- Pragma directives (.pragma library and pragma Singleton) are removed or broken.
Example:
Before:
function pointOnCircle(center, radius, angleDeg) { for(var i=0; i < 10; ++i) console.log("test", i) var x = center.x + (radius * Math.cos(deg2Rad(angleDeg - 90))) var y = center.y + (radius * Math.sin(deg2Rad(angleDeg - 90))) return Qt.point(x, y) } function deg2Rad(deg) { return deg * Math.PI / 180 }
After auto-formatting:
function pointOnCircle(centerradiusangleDeg) { for (; i < 10; ++i) console.log("test", i) var x = center.x + (radius * Math.cos(deg2Rad(angleDeg - 90))) var y = center.y + (radius * Math.sin(deg2Rad(angleDeg - 90))) return Qt.point(x, y) } function deg2Rad(deg) { return deg * Math.PI / 180 }
Attachments
Issue Links
- is duplicated by
-
QTCREATORBUG-22369 When using the reformat file under the QML option it can modify QML to be invalid
- Closed