forked from qt-creator/qt-creator
SyntaxHighlighter: Move highlighter creating to TextDocument
Added setSyntaxHighlighterCreator function to TextDocument which allows the creation of highlighters inside TextDocument. Change-Id: I454f800c878c48a154dad5abd68b7a4f9ceb378a Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -743,7 +743,7 @@ void QmlJSEditorWidget::inspectElementUnderCursor() const
|
||||
|
||||
widget->setReadOnly(true);
|
||||
widget->textDocument()->setTemporary(true);
|
||||
widget->textDocument()->setSyntaxHighlighter(new QmlJSHighlighter(widget->document()));
|
||||
widget->textDocument()->setSyntaxHighlighterCreator([] {return new QmlJSHighlighter();});
|
||||
|
||||
const QString buf = inspectCppComponent(cppValue);
|
||||
widget->textDocument()->setPlainText(buf);
|
||||
@@ -1160,7 +1160,7 @@ QmlJSEditorFactory::QmlJSEditorFactory(Utils::Id _id)
|
||||
|
||||
void QmlJSEditorFactory::decorateEditor(TextEditorWidget *editor)
|
||||
{
|
||||
editor->textDocument()->setSyntaxHighlighter(new QmlJSHighlighter);
|
||||
editor->textDocument()->setSyntaxHighlighterCreator([] { return new QmlJSHighlighter(); });
|
||||
editor->textDocument()->setIndenter(new Internal::Indenter(editor->textDocument()->document()));
|
||||
editor->setAutoCompleter(new AutoCompleter);
|
||||
}
|
||||
|
||||
@@ -820,7 +820,7 @@ QmlJSEditorDocument::QmlJSEditorDocument(Utils::Id id)
|
||||
d, &Internal::QmlJSEditorDocumentPrivate::invalidateFormatterCache);
|
||||
connect(this, &TextEditor::TextDocument::openFinishedSuccessfully,
|
||||
d, &Internal::QmlJSEditorDocumentPrivate::settingsChanged);
|
||||
setSyntaxHighlighter(new QmlJSHighlighter(document()));
|
||||
setSyntaxHighlighterCreator([] { return new QmlJSHighlighter(); });
|
||||
setCodec(QTextCodec::codecForName("UTF-8")); // qml files are defined to be utf-8
|
||||
setIndenter(new Internal::Indenter(document()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user