diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 6a2166d29b7ecc66cec75722e80c072856964926..1212a7be59b912eac8a0143e83e0330e7256f44d 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -749,12 +749,11 @@ static void appendExtraSelectionsForMessages( void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc) { - if (file()->fileName() != doc->fileName()) { - return; - } - - if (doc->documentRevision() != document()->revision()) { - // got an outdated document. + if (file()->fileName() != doc->fileName() + || doc->documentRevision() != document()->revision()) { + // didn't get the currently open, or an up to date document. + // trigger a semantic rehighlight anyway, after a time + updateDocument(); return; } @@ -764,6 +763,7 @@ void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc) const SemanticHighlighter::Source source = currentSource(/*force = */ true); m_semanticHighlighter->rehighlight(source); } else { + // show parsing errors QList<QTextEdit::ExtraSelection> selections; appendExtraSelectionsForMessages(&selections, doc->diagnosticMessages(), document()); setExtraSelections(CodeWarningsSelection, selections); diff --git a/src/plugins/qmljseditor/qmljsmodelmanager.cpp b/src/plugins/qmljseditor/qmljsmodelmanager.cpp index 52a781efdd83d2a9f28b8320c5a8f6e5d1971bf6..d21bda3660fbfccc9a6e8c02a8a7b95ca4fecb5b 100644 --- a/src/plugins/qmljseditor/qmljsmodelmanager.cpp +++ b/src/plugins/qmljseditor/qmljsmodelmanager.cpp @@ -100,7 +100,19 @@ Snapshot ModelManager::snapshot() const void ModelManager::updateSourceFiles(const QStringList &files) { - refreshSourceFiles(files); + // for files that are not yet in the snapshot, scan the whole directory + QStringList filesToParse; + QSet<QString> sourceDirectories; + + foreach (const QString &file, files) { + if (! _snapshot.document(file)) + sourceDirectories.insert(QFileInfo(file).path()); + else + filesToParse.append(file); + } + + refreshSourceFiles(filesToParse); + refreshSourceDirectories(sourceDirectories.toList()); } QFuture<void> ModelManager::refreshSourceFiles(const QStringList &sourceFiles) diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index a6ff729c8e38779b960fab46d6303a772ce5398d..f0f562330abcea9edeed3ccafa9b012f1913a39b 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -106,13 +106,7 @@ void QmlProject::parseProject(RefreshOptions options) } if (m_projectItem) { m_projectItem.data()->setSourceDirectory(projectDir().path()); - - QSet<QString> sourceDirectories; - foreach (const QString &file, m_projectItem.data()->files()) { - sourceDirectories.insert(QFileInfo(file).path()); - } - - m_modelManager->updateSourceDirectories(sourceDirectories.toList()); + m_modelManager->updateSourceDirectories(m_projectItem.data()->files()); } m_rootNode->refresh(); }