Commit e50aafaf authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppEditor: Fix semantic highlighting when zooming

...for the not visible documents.

First reset the extra additional formats, then set the new ones, not the
other way around.

Task-number: QTCREATORBUG-14579
Change-Id: Iae465bd9a7bb0a397fd4917df45955713aaf87c5
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent 4e2905f8
......@@ -167,6 +167,12 @@ void ClangEditorDocumentProcessor::recalculateSemanticInfoDetached(bool force)
m_builtinProcessor.recalculateSemanticInfoDetached(force);
}
void ClangEditorDocumentProcessor::semanticRehighlight()
{
m_semanticHighlighter.updateFormatMapFromFontSettings();
m_semanticHighlighter.run();
}
CppTools::SemanticInfo ClangEditorDocumentProcessor::recalculateSemanticInfo()
{
return m_builtinProcessor.recalculateSemanticInfo();
......
......@@ -56,6 +56,7 @@ public:
// BaseEditorDocumentProcessor interface
void run() override;
void semanticRehighlight() override;
void recalculateSemanticInfoDetached(bool force) override;
CppTools::SemanticInfo recalculateSemanticInfo() override;
CppTools::BaseEditorDocumentParser *parser() override;
......
......@@ -169,6 +169,7 @@ void CppEditorDocument::applyFontSettings()
}
}
TextDocument::applyFontSettings(); // rehighlights and updates additional formats
m_processor->semanticRehighlight();
}
void CppEditorDocument::invalidateFormatterCache()
......
......@@ -60,6 +60,7 @@ public:
// Function interface to implement
virtual void run() = 0;
virtual void semanticRehighlight() = 0;
virtual void recalculateSemanticInfoDetached(bool force) = 0;
virtual CppTools::SemanticInfo recalculateSemanticInfo() = 0;
virtual CPlusPlus::Snapshot snapshot() = 0;
......
......@@ -182,6 +182,14 @@ void BuiltinEditorDocumentProcessor::recalculateSemanticInfoDetached(bool force)
m_semanticInfoUpdater.updateDetached(source);
}
void BuiltinEditorDocumentProcessor::semanticRehighlight()
{
if (m_semanticHighlighter && m_semanticInfoUpdater.semanticInfo().doc) {
m_semanticHighlighter->updateFormatMapFromFontSettings();
m_semanticHighlighter->run();
}
}
SemanticInfo BuiltinEditorDocumentProcessor::recalculateSemanticInfo()
{
const auto source = createSemanticInfoSource(false);
......
......@@ -52,6 +52,7 @@ public:
// BaseEditorDocumentProcessor interface
void run() override;
void recalculateSemanticInfoDetached(bool force) override;
void semanticRehighlight() override;
CppTools::SemanticInfo recalculateSemanticInfo() override;
BaseEditorDocumentParser *parser() override;
CPlusPlus::Snapshot snapshot() override;
......
......@@ -54,10 +54,6 @@ SemanticHighlighter::SemanticHighlighter(TextEditor::TextDocument *baseTextDocum
, m_revision(0)
{
QTC_CHECK(m_baseTextDocument);
connect(baseTextDocument, &TextEditor::TextDocument::fontSettingsChanged,
this, &SemanticHighlighter::onDocumentFontSettingsChanged);
updateFormatMapFromFontSettings();
}
......@@ -92,12 +88,6 @@ void SemanticHighlighter::run()
m_watcher->setFuture(m_highlightingRunner());
}
void SemanticHighlighter::onDocumentFontSettingsChanged()
{
updateFormatMapFromFontSettings();
run();
}
void SemanticHighlighter::onHighlighterResultAvailable(int from, int to)
{
if (documentRevision() != m_revision)
......
......@@ -73,12 +73,11 @@ public:
~SemanticHighlighter();
void setHighlightingRunner(HighlightingRunner highlightingRunner);
void updateFormatMapFromFontSettings();
void run();
private slots:
void onDocumentFontSettingsChanged();
void onHighlighterResultAvailable(int from, int to);
void onHighlighterFinished();
......@@ -87,7 +86,6 @@ private:
void disconnectWatcher();
unsigned documentRevision() const;
void updateFormatMapFromFontSettings();
private:
TextEditor::TextDocument *m_baseTextDocument;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment