diff --git a/src/libs/qmljs/qmljscompletioncontextfinder.cpp b/src/libs/qmljs/qmljscompletioncontextfinder.cpp
index 645472c220340e682f008bcf670036e3ef889793..c316b7b4a74672a3e2681af2af0a8aa717dee268 100644
--- a/src/libs/qmljs/qmljscompletioncontextfinder.cpp
+++ b/src/libs/qmljs/qmljscompletioncontextfinder.cpp
@@ -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();