Commit 44a155c6 authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Fix completion context when cursor is to the right of inserted ;

Done-with: Erik Verbruggen
parent 0970a8e6
......@@ -31,6 +31,9 @@ CompletionContextFinder::CompletionContextFinder(const QTextCursor &cursor)
break;
}
if (m_startTokenIndex == yyLinizerState.tokens.size() - 1 && yyLinizerState.insertedSemicolon)
--m_startTokenIndex;
getQmlObjectTypeName(m_startTokenIndex);
checkBinding();
}
......
......@@ -208,6 +208,7 @@ QString LineInfo::trimmedCodeLine(const QString &t)
const Token sc(trimmed.size(), 1, Token::Semicolon);
yyLinizerState.tokens.append(sc);
trimmed.append(QLatin1Char(';'));
yyLinizerState.insertedSemicolon = true;
}
}
......@@ -276,6 +277,8 @@ bool LineInfo::readLine()
(firstNonWhiteSpace(yyLinizerState.line) == QLatin1Char('{'));
do {
yyLinizerState.insertedSemicolon = false;
if (yyLinizerState.iter == yyProgram.firstBlock()) {
yyLinizerState.line.clear();
return false;
......@@ -332,6 +335,7 @@ void LineInfo::startLinizer()
{
yyLinizerState.braceDepth = 0;
yyLinizerState.pendingRightBrace = false;
yyLinizerState.insertedSemicolon = false;
yyLine = &yyLinizerState.line;
yyBraceDepth = &yyLinizerState.braceDepth;
......
......@@ -84,12 +84,14 @@ protected:
LinizerState()
: braceDepth(0),
leftBraceFollows(false),
pendingRightBrace(false)
pendingRightBrace(false),
insertedSemicolon(false)
{ }
int braceDepth;
bool leftBraceFollows;
bool pendingRightBrace;
bool insertedSemicolon;
QString line;
QList<Token> tokens;
QTextBlock iter;
......
......@@ -690,7 +690,6 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
if (contextFinder.isInRhsOfBinding() && qmlScopeType) {
doQmlKeywordCompletion = false;
qDebug() << "property name: " << contextFinder.bindingPropertyName();
if (!contextFinder.bindingPropertyName().isEmpty()) {
const Interpreter::Value *value = qmlScopeType;
......
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