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:
@@ -760,9 +760,11 @@ void VcsBaseEditorWidget::init()
|
||||
break;
|
||||
}
|
||||
if (hasDiff()) {
|
||||
auto dh = new DiffAndLogHighlighter(d->m_diffFilePattern, d->m_logEntryPattern);
|
||||
setCodeFoldingSupported(true);
|
||||
textDocument()->setSyntaxHighlighter(dh);
|
||||
textDocument()->setSyntaxHighlighterCreator(
|
||||
[diffFilePattern = d->m_diffFilePattern, logEntryPattern = d->m_logEntryPattern] {
|
||||
return new DiffAndLogHighlighter(diffFilePattern, logEntryPattern);
|
||||
});
|
||||
}
|
||||
// override revisions display (green or red bar on the left, marking changes):
|
||||
setRevisionsVisible(false);
|
||||
@@ -1102,7 +1104,8 @@ void VcsBaseEditorWidget::slotActivateAnnotation()
|
||||
ah->setChangeNumbers(changes);
|
||||
ah->rehighlight();
|
||||
} else {
|
||||
textDocument()->setSyntaxHighlighter(createAnnotationHighlighter(changes));
|
||||
BaseAnnotationHighlighter *highlighter = createAnnotationHighlighter(changes);
|
||||
textDocument()->setSyntaxHighlighterCreator([highlighter] { return highlighter; });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user