Commit a9a7f045 authored by Rhys Weatherley's avatar Rhys Weatherley Committed by Roberto Raggi
Browse files

Fix syntax highlighting of multiline QMLJS strings

parent 90bf956c
......@@ -152,6 +152,25 @@ QList<Token> Scanner::operator()(const QString &text, int startState)
if (_scanComments && start != -1)
tokens.append(Token(start, index - start, Token::Comment));
} else if (_state == MultiLineStringDQuote || _state == MultiLineStringSQuote) {
const QChar quote = (_state == MultiLineStringDQuote ? QLatin1Char('"') : QLatin1Char('\''));
const int start = index;
while (index < text.length()) {
const QChar ch = text.at(index);
if (ch == quote)
break;
else if (index + 1 < text.length() && ch == QLatin1Char('\\'))
index += 2;
else
++index;
}
if (index < text.length()) {
++index;
_state = Normal;
}
if (start < index)
tokens.append(Token(start, index - start, Token::String));
}
while (index < text.length()) {
......@@ -212,7 +231,10 @@ QList<Token> Scanner::operator()(const QString &text, int startState)
++index;
// good one
} else {
// unfinished
if (quote.unicode() == '"')
_state = MultiLineStringDQuote;
else
_state = MultiLineStringSQuote;
}
tokens.append(Token(start, index - start, Token::String));
......
......@@ -79,7 +79,9 @@ class QMLJS_EXPORT Scanner
public:
enum {
Normal = 0,
MultiLineComment = 1
MultiLineComment = 1,
MultiLineStringDQuote = 2,
MultiLineStringSQuote = 3
};
Scanner();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment