jesperhh / qmlfmt

qmlfmt - command line application that formats QML files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Doesn't work with JS lambdas

angusdavisadobe opened this issue · comments

with this QML:
onPressed: (mouse)=> {
if (mouse.modifiers & Qt.AltModifier) {
if (mouse.button == Qt.LeftButton) {
state = 1;
} else if (mouse.button == Qt.RightButton) {
state = 2;
} else if (mouse.button == Qt.MiddleButton) {
state = 3;
}
}
it produced:
onPressed: function mouse }
if (mouse.modifiers & Qt.AltModifier) {
if (mouse.button == Qt.LeftButton) {
state = 1
} else if (mouse.button == Qt.RightButton) {
state = 2
} else if (mouse.button == Qt.MiddleButton) {
state = 3
}
}

If you have a recent version of Qt Creator installed, can you check if the same issue reproduces if you reformat there?

I was using the command-line interface. I don't have Qt Creator project so can't test there.

Looks like this was mostly fixed in: https://bugreports.qt.io/browse/QTCREATORBUG-23019

Unfortunately, this case is still buggy, with Qt Cretor 6.0 it becomes:

import QtQuick 2.7

Item {
    MouseArea {
        onPressed: mouse =>
                   if (mouse.modifiers & Qt.AltModifier) {
                       if (mouse.button === Qt.LeftButton) {
                           state = 1
                       } else if (mouse.button === Qt.RightButton) {
                           state = 2
                       } else if (mouse.button === Qt.MiddleButton) {
                           state = 3
                       }
                   }
    }
}
}

You will need to report this bug against Qt Creator, as that is what this tool is built on.