diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index ba9392b33639684d27f3bf1ba3cfd14fb666593a..33f754290fa13d9a61ee169b4462fcc28eba7671 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -803,9 +803,6 @@ void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc) { if (file()->fileName() != doc->fileName() || doc->editorRevision() != document()->revision()) { - // didn't get the currently open, or an up to date document. - // trigger a semantic rehighlight anyway, after a time - m_semanticRehighlightTimer->start(); return; } diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h index d0ac90101ae03610fea9a159adcf37f02776a791..154dbe4eabd96cb210dc5fc28fc7b3632a373118 100644 --- a/src/plugins/qmljseditor/qmljseditor.h +++ b/src/plugins/qmljseditor/qmljseditor.h @@ -158,6 +158,7 @@ public: static QVector<QString> highlighterFormatCategories(); public slots: + void forceSemanticRehighlight(); void followSymbolUnderCursor(); void findUsages(); void showContextPane(); @@ -187,7 +188,6 @@ private slots: void renameIdUnderCursor(); void semanticRehighlight(); - void forceSemanticRehighlight(); void updateSemanticInfo(const QmlJSEditor::SemanticInfo &semanticInfo); void onCursorPositionChanged(); void onRefactorMarkerClicked(const TextEditor::RefactorMarker &marker); diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index ef36284062196ba7136e7471b5d277c5e130481a..31385027cdd099da34eb36bbfe925044562e6478 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -241,6 +241,8 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e addAutoReleasedObject(new QuickToolBar); addAutoReleasedObject(new Internal::QuickToolBarSettingsPage); + connect(core->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(currentEditorChanged(Core::IEditor*))); + return true; } @@ -340,4 +342,14 @@ void QmlJSEditorPlugin::quickFixNow() } } +void QmlJSEditorPlugin::currentEditorChanged(Core::IEditor *editor) +{ + if (! editor) + return; + + else if (QmlJSTextEditor *textEditor = qobject_cast<QmlJSTextEditor *>(editor->widget())) { + textEditor->forceSemanticRehighlight(); + } +} + Q_EXPORT_PLUGIN(QmlJSEditorPlugin) diff --git a/src/plugins/qmljseditor/qmljseditorplugin.h b/src/plugins/qmljseditor/qmljseditorplugin.h index 786a2f2675527b680f32f7bc45b6987208039420..265f69c106b5cdb2e5692502a5736a09c43ce3e7 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.h +++ b/src/plugins/qmljseditor/qmljseditorplugin.h @@ -45,6 +45,7 @@ namespace Core { class Command; class ActionContainer; class ActionManager; +class IEditor; } namespace TextEditor { @@ -95,6 +96,7 @@ public Q_SLOTS: private Q_SLOTS: void quickFix(TextEditor::ITextEditable *editable); void quickFixNow(); + void currentEditorChanged(Core::IEditor *editor); private: Core::Command *addToolAction(QAction *a, Core::ActionManager *am, Core::Context &context, const QString &name,