From a94d7368815c435b24bfab4c06de2bc52d627ee1 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 30 Jan 2014 12:48:30 +0100 Subject: [PATCH] TextEditors: Avoid sending contentsChanged signal when rehighlighting That avoids a complete reparse of the document when font settings change, but in turn now requires an explicit redo of semantic highlighting in that case. The cpp editor part of this patch is actually still doing semantic parsing though. This will be fixed up in a later patch. Change-Id: I6f51a18cba6325856c96e155700eb912f6d3aad5 Reviewed-by: Fawzi Mohamed --- src/plugins/cppeditor/cppeditor.cpp | 1 + src/plugins/qmljseditor/qmljseditor.cpp | 4 ++++ src/plugins/texteditor/syntaxhighlighter.cpp | 2 -- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 819390fad3a..e71f4cb8456 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -1557,6 +1557,7 @@ void CPPEditorWidget::applyFontSettings() // this also makes the document apply font settings TextEditor::BaseTextEditorWidget::applyFontSettings(); + semanticRehighlight(true); } void CPPEditorWidget::unCommentSelection() diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 0b6c30d5411..a47daa5dd80 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -569,6 +569,10 @@ void QmlJSTextEditorWidget::applyFontSettings() { TextEditor::BaseTextEditorWidget::applyFontSettings(); m_semanticHighlighter->updateFontSettings(baseTextDocument()->fontSettings()); + if (!m_qmlJsEditorDocument->isSemanticInfoOutdated()) { + m_semanticHighlighter->rerun(m_qmlJsEditorDocument->semanticInfo()); + updateUses(); + } } diff --git a/src/plugins/texteditor/syntaxhighlighter.cpp b/src/plugins/texteditor/syntaxhighlighter.cpp index 0f54d2f01c4..4ffed2a4a07 100644 --- a/src/plugins/texteditor/syntaxhighlighter.cpp +++ b/src/plugins/texteditor/syntaxhighlighter.cpp @@ -58,11 +58,9 @@ public: inline void rehighlight(QTextCursor &cursor, QTextCursor::MoveOperation operation) { inReformatBlocks = true; - cursor.beginEditBlock(); int from = cursor.position(); cursor.movePosition(operation); reformatBlocks(from, 0, cursor.position() - from); - cursor.endEditBlock(); inReformatBlocks = false; }