forked from qt-creator/qt-creator
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 <orgads@gmail.com> Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
@@ -167,6 +167,12 @@ void ClangEditorDocumentProcessor::recalculateSemanticInfoDetached(bool force)
|
|||||||
m_builtinProcessor.recalculateSemanticInfoDetached(force);
|
m_builtinProcessor.recalculateSemanticInfoDetached(force);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClangEditorDocumentProcessor::semanticRehighlight()
|
||||||
|
{
|
||||||
|
m_semanticHighlighter.updateFormatMapFromFontSettings();
|
||||||
|
m_semanticHighlighter.run();
|
||||||
|
}
|
||||||
|
|
||||||
CppTools::SemanticInfo ClangEditorDocumentProcessor::recalculateSemanticInfo()
|
CppTools::SemanticInfo ClangEditorDocumentProcessor::recalculateSemanticInfo()
|
||||||
{
|
{
|
||||||
return m_builtinProcessor.recalculateSemanticInfo();
|
return m_builtinProcessor.recalculateSemanticInfo();
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public:
|
|||||||
|
|
||||||
// BaseEditorDocumentProcessor interface
|
// BaseEditorDocumentProcessor interface
|
||||||
void run() override;
|
void run() override;
|
||||||
|
void semanticRehighlight() override;
|
||||||
void recalculateSemanticInfoDetached(bool force) override;
|
void recalculateSemanticInfoDetached(bool force) override;
|
||||||
CppTools::SemanticInfo recalculateSemanticInfo() override;
|
CppTools::SemanticInfo recalculateSemanticInfo() override;
|
||||||
CppTools::BaseEditorDocumentParser *parser() override;
|
CppTools::BaseEditorDocumentParser *parser() override;
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ void CppEditorDocument::applyFontSettings()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
TextDocument::applyFontSettings(); // rehighlights and updates additional formats
|
TextDocument::applyFontSettings(); // rehighlights and updates additional formats
|
||||||
|
m_processor->semanticRehighlight();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorDocument::invalidateFormatterCache()
|
void CppEditorDocument::invalidateFormatterCache()
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ public:
|
|||||||
|
|
||||||
// Function interface to implement
|
// Function interface to implement
|
||||||
virtual void run() = 0;
|
virtual void run() = 0;
|
||||||
|
virtual void semanticRehighlight() = 0;
|
||||||
virtual void recalculateSemanticInfoDetached(bool force) = 0;
|
virtual void recalculateSemanticInfoDetached(bool force) = 0;
|
||||||
virtual CppTools::SemanticInfo recalculateSemanticInfo() = 0;
|
virtual CppTools::SemanticInfo recalculateSemanticInfo() = 0;
|
||||||
virtual CPlusPlus::Snapshot snapshot() = 0;
|
virtual CPlusPlus::Snapshot snapshot() = 0;
|
||||||
|
|||||||
@@ -182,6 +182,14 @@ void BuiltinEditorDocumentProcessor::recalculateSemanticInfoDetached(bool force)
|
|||||||
m_semanticInfoUpdater.updateDetached(source);
|
m_semanticInfoUpdater.updateDetached(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BuiltinEditorDocumentProcessor::semanticRehighlight()
|
||||||
|
{
|
||||||
|
if (m_semanticHighlighter && m_semanticInfoUpdater.semanticInfo().doc) {
|
||||||
|
m_semanticHighlighter->updateFormatMapFromFontSettings();
|
||||||
|
m_semanticHighlighter->run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SemanticInfo BuiltinEditorDocumentProcessor::recalculateSemanticInfo()
|
SemanticInfo BuiltinEditorDocumentProcessor::recalculateSemanticInfo()
|
||||||
{
|
{
|
||||||
const auto source = createSemanticInfoSource(false);
|
const auto source = createSemanticInfoSource(false);
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public:
|
|||||||
// BaseEditorDocumentProcessor interface
|
// BaseEditorDocumentProcessor interface
|
||||||
void run() override;
|
void run() override;
|
||||||
void recalculateSemanticInfoDetached(bool force) override;
|
void recalculateSemanticInfoDetached(bool force) override;
|
||||||
|
void semanticRehighlight() override;
|
||||||
CppTools::SemanticInfo recalculateSemanticInfo() override;
|
CppTools::SemanticInfo recalculateSemanticInfo() override;
|
||||||
BaseEditorDocumentParser *parser() override;
|
BaseEditorDocumentParser *parser() override;
|
||||||
CPlusPlus::Snapshot snapshot() override;
|
CPlusPlus::Snapshot snapshot() override;
|
||||||
|
|||||||
@@ -54,10 +54,6 @@ SemanticHighlighter::SemanticHighlighter(TextEditor::TextDocument *baseTextDocum
|
|||||||
, m_revision(0)
|
, m_revision(0)
|
||||||
{
|
{
|
||||||
QTC_CHECK(m_baseTextDocument);
|
QTC_CHECK(m_baseTextDocument);
|
||||||
|
|
||||||
connect(baseTextDocument, &TextEditor::TextDocument::fontSettingsChanged,
|
|
||||||
this, &SemanticHighlighter::onDocumentFontSettingsChanged);
|
|
||||||
|
|
||||||
updateFormatMapFromFontSettings();
|
updateFormatMapFromFontSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,12 +88,6 @@ void SemanticHighlighter::run()
|
|||||||
m_watcher->setFuture(m_highlightingRunner());
|
m_watcher->setFuture(m_highlightingRunner());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SemanticHighlighter::onDocumentFontSettingsChanged()
|
|
||||||
{
|
|
||||||
updateFormatMapFromFontSettings();
|
|
||||||
run();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SemanticHighlighter::onHighlighterResultAvailable(int from, int to)
|
void SemanticHighlighter::onHighlighterResultAvailable(int from, int to)
|
||||||
{
|
{
|
||||||
if (documentRevision() != m_revision)
|
if (documentRevision() != m_revision)
|
||||||
|
|||||||
@@ -73,12 +73,11 @@ public:
|
|||||||
~SemanticHighlighter();
|
~SemanticHighlighter();
|
||||||
|
|
||||||
void setHighlightingRunner(HighlightingRunner highlightingRunner);
|
void setHighlightingRunner(HighlightingRunner highlightingRunner);
|
||||||
|
void updateFormatMapFromFontSettings();
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDocumentFontSettingsChanged();
|
|
||||||
|
|
||||||
void onHighlighterResultAvailable(int from, int to);
|
void onHighlighterResultAvailable(int from, int to);
|
||||||
void onHighlighterFinished();
|
void onHighlighterFinished();
|
||||||
|
|
||||||
@@ -87,7 +86,6 @@ private:
|
|||||||
void disconnectWatcher();
|
void disconnectWatcher();
|
||||||
|
|
||||||
unsigned documentRevision() const;
|
unsigned documentRevision() const;
|
||||||
void updateFormatMapFromFontSettings();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextEditor::TextDocument *m_baseTextDocument;
|
TextEditor::TextDocument *m_baseTextDocument;
|
||||||
|
|||||||
Reference in New Issue
Block a user