qmljs: preserve default arguments when reformatting QML

Fixes: QTCREATORBUG-23009
Change-Id: I9949fe26a91a063c4804fddcca4e26d14bc5cd61
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Fawzi Mohamed
2021-02-23 08:45:09 +01:00
parent 0ff75a721f
commit 9e4e44d180
2 changed files with 3 additions and 3 deletions

View File

@@ -1023,7 +1023,7 @@ protected:
} }
out(ast->identifierToken); out(ast->identifierToken);
if (ast->initializer) { if (ast->initializer) {
if (ast->isVariableDeclaration()) if (ast->isVariableDeclaration() || ast->type == PatternElement::Binding)
out(" = "); out(" = ");
accept(ast->initializer); accept(ast->initializer);
} }
@@ -1394,7 +1394,7 @@ protected:
bool visit(FormalParameterList *ast) override bool visit(FormalParameterList *ast) override
{ {
for (FormalParameterList *it = ast; it; it = it->next) { for (FormalParameterList *it = ast; it; it = it->next) {
out(it->element->bindingIdentifier.toString()); // TODO accept(it->element);
if (it->next) if (it->next)
out(", "); out(", ");
} }

View File

@@ -15,7 +15,7 @@ function foo(a, b) {
x += 4 x += 4
} }
var foo = function (a, b) {} var foo = function (a, b = 0) {}
function spread() { function spread() {
iterableObj = [1, 2] iterableObj = [1, 2]