From 08f3c10bf522ba3c12db00c01b2de1f180de6207 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 20 Sep 2021 15:13:44 +0200 Subject: [PATCH] CppEditor: Fix clearing of "semantic parentheses" Amends a0bf5448a1. Change-Id: I0a89834ade9b5df7aa976278fdc5761eb1c0ac24 Reviewed-by: David Schulz --- src/plugins/cppeditor/semantichighlighter.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/cppeditor/semantichighlighter.cpp b/src/plugins/cppeditor/semantichighlighter.cpp index 3e9160239a7..9a7764e1344 100644 --- a/src/plugins/cppeditor/semantichighlighter.cpp +++ b/src/plugins/cppeditor/semantichighlighter.cpp @@ -241,9 +241,14 @@ void SemanticHighlighter::onHighlighterFinished() } else { firstResultBlock = m_baseTextDocument->document()->findBlockByNumber( m_watcher->resultAt(0).line - 1); - lastResultBlock = m_baseTextDocument->document()->findBlockByNumber( - m_watcher->future().resultAt(m_watcher->future().resultCount() - 1).line - 1); + const HighlightingResult &lastResult + = m_watcher->future().resultAt(m_watcher->future().resultCount() - 1); + const QTextBlock lastResultStartBlock + = m_baseTextDocument->document()->findBlockByNumber(lastResult.line - 1); + lastResultBlock = m_baseTextDocument->document()->findBlock( + lastResultStartBlock.position() + lastResult.column - 1 + lastResult.length); } + for (QTextBlock currentBlock = m_baseTextDocument->document()->firstBlock(); currentBlock != firstResultBlock; currentBlock = currentBlock.next()) { TextDocumentLayout::setParentheses(currentBlock, getClearedParentheses(currentBlock));