diff options
author | Eike Ziller <eike.ziller@qt.io> | 2019-03-14 15:14:40 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2019-03-14 15:51:15 +0100 |
commit | c53ccceff1e1642b7704fa8b0681604c25a833a0 (patch) | |
tree | 7258d63fba4dabd6f9e2f2f36089ce45df7fe3af /src/plugins/texteditor/highlighter.cpp | |
parent | 62cafc1782369cde0605fbd6b1182a83d5473a12 (diff) | |
parent | 429eb73ace5909e228a58bf8b067823e2be44212 (diff) |
Merge remote-tracking branch 'origin/4.9'
Conflicts:
qbs/modules/qtc/qtc.qbs
qtcreator.pri
src/plugins/debugger/debuggerkitinformation.cpp
src/plugins/languageclient/languageclientmanager.cpp
src/plugins/plugins.pro
src/plugins/projectexplorer/kit.cpp
src/plugins/projectexplorer/kitmanager.cpp
Change-Id: I66fb941202991f35f7d7761430b21e42dfc678a8
Diffstat (limited to 'src/plugins/texteditor/highlighter.cpp')
-rw-r--r-- | src/plugins/texteditor/highlighter.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/plugins/texteditor/highlighter.cpp b/src/plugins/texteditor/highlighter.cpp index 4178dc7195f..5b60b885ab4 100644 --- a/src/plugins/texteditor/highlighter.cpp +++ b/src/plugins/texteditor/highlighter.cpp @@ -258,6 +258,16 @@ void Highlighter::handleShutdown() delete highlightRepository(); } +static bool isOpeningParenthesis(QChar c) +{ + return c == QLatin1Char('{') || c == QLatin1Char('[') || c == QLatin1Char('('); +} + +static bool isClosingParenthesis(QChar c) +{ + return c == QLatin1Char('}') || c == QLatin1Char(']') || c == QLatin1Char(')'); +} + void Highlighter::highlightBlock(const QString &text) { if (!definition().isValid()) @@ -266,8 +276,21 @@ void Highlighter::highlightBlock(const QString &text) KSyntaxHighlighting::State state = TextDocumentLayout::userData(block)->syntaxState(); state = highlightLine(text, state); block = block.next(); + + Parentheses parentheses; + int pos = 0; + for (const QChar &c : text) { + if (isOpeningParenthesis(c)) + parentheses.push_back(Parenthesis(Parenthesis::Opened, c, pos)); + else if (isClosingParenthesis(c)) + parentheses.push_back(Parenthesis(Parenthesis::Closed, c, pos)); + pos++; + } + TextDocumentLayout::setParentheses(currentBlock(), parentheses); + if (block.isValid()) TextDocumentLayout::userData(block)->setSyntaxState(state); + formatSpaces(text); } void Highlighter::applyFormat(int offset, int length, const KSyntaxHighlighting::Format &format) |