aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cpptools
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2021-07-30 12:35:25 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2021-08-02 08:21:50 +0000
commitf84e4ea8ccdaa2b422255ec61bbf573a78030edf (patch)
treea10df7545240c0062ed11efeac929913a68c5e19 /src/plugins/cpptools
parent6839ad0118ecadafc28e911498215528b2834872 (diff)
CppTools: Fix semantic highlighting
It turns out the parentheses information for the TextEditor has to be in order of occurrence in the document. Fixes: QTCREATORBUG-26068 Change-Id: I5335160f81355bac6b1431cad25a31b70f03e8f4 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/cpptools')
-rw-r--r--src/plugins/cpptools/semantichighlighter.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/plugins/cpptools/semantichighlighter.cpp b/src/plugins/cpptools/semantichighlighter.cpp
index 67ce04e042..d30f4d97c5 100644
--- a/src/plugins/cpptools/semantichighlighter.cpp
+++ b/src/plugins/cpptools/semantichighlighter.cpp
@@ -210,7 +210,13 @@ void SemanticHighlighter::onHighlighterResultAvailable(int from, int to)
}
QTC_ASSERT(paren.pos != -1, continue);
paren.source = parenSource();
- parentheses.second << paren;
+
+ static const auto posCmp = [](const Parenthesis &p1, const Parenthesis &p2) {
+ return p1.pos < p2.pos;
+ };
+ const auto it = std::lower_bound(parentheses.second.begin(), parentheses.second.end(),
+ paren, posCmp);
+ parentheses.second.insert(it, paren);
}
if (parentheses.first.isValid())
TextDocumentLayout::setParentheses(parentheses.first, parentheses.second);