diff options
-rw-r--r-- | src/plugins/clangcodemodel/clangdiagnosticmanager.cpp | 15 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/clangdiagnosticmanager.h | 3 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp index c8da6e6c6a..1dd003c7c1 100644 --- a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp +++ b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp @@ -278,6 +278,8 @@ namespace Internal { ClangDiagnosticManager::ClangDiagnosticManager(TextEditor::TextDocument *textDocument) : m_textDocument(textDocument) { + m_textMarkDelay.setInterval(1500); + m_textMarkDelay.setSingleShot(true); } ClangDiagnosticManager::~ClangDiagnosticManager() @@ -295,6 +297,7 @@ void ClangDiagnosticManager::cleanMarks() } void ClangDiagnosticManager::generateTextMarks() { + QObject::disconnect(&m_textMarkDelay, &QTimer::timeout, 0, 0); cleanMarks(); m_clangTextMarks.reserve(m_warningDiagnostics.size() + m_errorDiagnostics.size()); addClangTextMarks(m_warningDiagnostics); @@ -350,6 +353,7 @@ ClangDiagnosticManager::diagnosticsAt(uint line, uint column) const void ClangDiagnosticManager::invalidateDiagnostics() { + m_textMarkDelay.start(); if (m_diagnosticsInvalidated) return; @@ -383,9 +387,18 @@ void ClangDiagnosticManager::processNewDiagnostics( m_showTextMarkAnnotations = showTextMarkAnnotations; filterDiagnostics(allDiagnostics); - generateTextMarks(); generateEditorSelections(); generateFixItAvailableMarkers(); + if (m_firstDiagnostics) { + m_firstDiagnostics = false; + generateTextMarks(); + } else if (!m_textMarkDelay.isActive()) { + generateTextMarks(); + } else { + QObject::connect(&m_textMarkDelay, &QTimer::timeout, [this]() { + generateTextMarks(); + }); + } } const QVector<ClangBackEnd::DiagnosticContainer> & diff --git a/src/plugins/clangcodemodel/clangdiagnosticmanager.h b/src/plugins/clangcodemodel/clangdiagnosticmanager.h index 16b1c16d2d..1321702c99 100644 --- a/src/plugins/clangcodemodel/clangdiagnosticmanager.h +++ b/src/plugins/clangcodemodel/clangdiagnosticmanager.h @@ -34,6 +34,7 @@ #include <QList> #include <QSet> #include <QTextEdit> +#include <QTimer> #include <QVector> #include <vector> @@ -82,8 +83,10 @@ private: QList<QTextEdit::ExtraSelection> m_extraSelections; TextEditor::RefactorMarkers m_fixItAvailableMarkers; std::vector<ClangTextMark *> m_clangTextMarks; + bool m_firstDiagnostics = true; bool m_diagnosticsInvalidated = false; bool m_showTextMarkAnnotations = false; + QTimer m_textMarkDelay; }; } // namespace Internal |