diff --git a/src/libs/qmljs/qmljsreformatter.cpp b/src/libs/qmljs/qmljsreformatter.cpp index ab43c037067..6c4befa0f84 100644 --- a/src/libs/qmljs/qmljsreformatter.cpp +++ b/src/libs/qmljs/qmljsreformatter.cpp @@ -150,8 +150,12 @@ protected: void outCommentText(const QString &str) { QStringList lines = str.split(QLatin1Char('\n')); + bool multiline = lines.length() > 1; for (int i = 0; i < lines.size(); ++i) { - _line = lines.at(i); // multiline comments don't keep track of previos lines + if (multiline) + _line = lines.at(i); // multiline comments don't keep track of previos lines + else + _line += lines.at(i); if (i != lines.size() - 1) newLine(); } @@ -582,7 +586,7 @@ protected: out(ast->identifierToken); } } else { // signal - out("signal "); + out("signal ", ast->identifierToken); out(ast->identifierToken); if (ast->parameters) { out("("); diff --git a/tests/auto/qml/reformatter/comments.qml b/tests/auto/qml/reformatter/comments.qml index 61889ea0079..5bffa03d814 100644 --- a/tests/auto/qml/reformatter/comments.qml +++ b/tests/auto/qml/reformatter/comments.qml @@ -13,4 +13,14 @@ Item { /* Indented multiline comment. */ + + // Comment over a signal. + signal foo + + function test() { + for (var i = model.count - 1; i >= 0; --i) // in-line comment + { + console.log("test") + } + } }