Commit fc362809 authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Fix completion context finder if cursor is on empty line.

It would calculate an incorrect start token in this case as the
linizer skips past the empty line.

Task-number: QTCREATORBUG-1412
parent 5193cef3
......@@ -25,14 +25,19 @@ CompletionContextFinder::CompletionContextFinder(const QTextCursor &cursor)
initialize(cursor.document()->begin(), lastBlock);
m_startTokenIndex = yyLinizerState.tokens.size() - 1;
for (; m_startTokenIndex >= 0; --m_startTokenIndex) {
const Token &token = yyLinizerState.tokens.at(m_startTokenIndex);
if (token.end() <= cursor.positionInBlock())
break;
}
if (m_startTokenIndex == yyLinizerState.tokens.size() - 1 && yyLinizerState.insertedSemicolon)
--m_startTokenIndex;
// Initialize calls readLine - which skips empty lines. We should only adjust
// the start token index if the linizer still is in the same block as the cursor.
if (yyLinizerState.iter == cursor.block()) {
for (; m_startTokenIndex >= 0; --m_startTokenIndex) {
const Token &token = yyLinizerState.tokens.at(m_startTokenIndex);
if (token.end() <= cursor.positionInBlock())
break;
}
if (m_startTokenIndex == yyLinizerState.tokens.size() - 1 && yyLinizerState.insertedSemicolon)
--m_startTokenIndex;
}
getQmlObjectTypeName(m_startTokenIndex);
checkBinding();
......
Supports Markdown
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