diff --git a/src/plugins/qmldesigner/components/texteditor/texteditorwidget.cpp b/src/plugins/qmldesigner/components/texteditor/texteditorwidget.cpp index 944fc34753b..461ff57753d 100644 --- a/src/plugins/qmldesigner/components/texteditor/texteditorwidget.cpp +++ b/src/plugins/qmldesigner/components/texteditor/texteditorwidget.cpp @@ -30,6 +30,8 @@ #include +#include + #include #include @@ -68,6 +70,8 @@ void TextEditorWidget::setTextEditor(TextEditor::BaseTextEditor *textEditor) layout()->addWidget(m_statusBar); setFocusProxy(textEditor->editorWidget()); + QmlDesignerPlugin::instance()->emitCurrentTextEditorChanged(textEditor); + connect(textEditor->editorWidget(), &QPlainTextEdit::cursorPositionChanged, &m_updateSelectionTimer, static_cast(&QTimer::start)); textEditor->editorWidget()->installEventFilter(this); diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp index aa0a48db097..2c90414fa65 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.cpp +++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp @@ -82,6 +82,7 @@ public: DesignerSettings settings; Internal::DesignModeContext *context = nullptr; + bool blockEditorChange = false; }; QmlDesignerPlugin *QmlDesignerPlugin::m_instance = nullptr; @@ -345,6 +346,9 @@ void QmlDesignerPlugin::hideDesigner() void QmlDesignerPlugin::changeEditor() { + if (d->blockEditorChange) + return; + if (d->documentManager.hasCurrentDesignDocument()) { deactivateAutoSynchronization(); d->mainWidget->saveSettings(); @@ -472,6 +476,13 @@ void QmlDesignerPlugin::switchToTextModeDeferred() }); } +void QmlDesignerPlugin::emitCurrentTextEditorChanged(Core::IEditor *editor) +{ + d->blockEditorChange = true; + Core::EditorManager::instance()->currentEditorChanged(editor); + d->blockEditorChange = false; +} + QmlDesignerPlugin *QmlDesignerPlugin::instance() { return m_instance; diff --git a/src/plugins/qmldesigner/qmldesignerplugin.h b/src/plugins/qmldesigner/qmldesignerplugin.h index ee98e56cb12..6e4b8fb2dec 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.h +++ b/src/plugins/qmldesigner/qmldesignerplugin.h @@ -83,6 +83,7 @@ public: Internal::DesignModeWidget *mainWidget() const; void switchToTextModeDeferred(); + void emitCurrentTextEditorChanged(Core::IEditor *editor); private: // functions void integrateIntoQtCreator(QWidget *modeWidget);