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,6 +25,10 @@ CompletionContextFinder::CompletionContextFinder(const QTextCursor &cursor)
initialize(cursor.document()->begin(), lastBlock);
m_startTokenIndex = yyLinizerState.tokens.size() - 1;
// 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 =;
if (token.end() <= cursor.positionInBlock())
......@@ -33,6 +37,7 @@ CompletionContextFinder::CompletionContextFinder(const QTextCursor &cursor)
if (m_startTokenIndex == yyLinizerState.tokens.size() - 1 && yyLinizerState.insertedSemicolon)
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