Commit acf79d7f authored by Francois Ferrand's avatar Francois Ferrand Committed by Nikolai Kosjar

CppTools: Fix C++ diagnostics hightlighting.

When the length of the highlight is specified, the code does not properly
check for end of line. This causes some lines to be highlighted when only
the last word was supposed to be.

For example, with this code:
   1: void foo(int x);
   2: int a = foo
   3:            ();
   4: int b = foo(
   5:             );
line 2 and 4 used to be completely highlighted (underlined), instead of
just 'foo'.

Change-Id: I40e895410ce0f38bad0adbccd509fd2943c93c97
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 4b44d2c6
......@@ -95,9 +95,9 @@ QList<QTextEdit::ExtraSelection> BaseEditorDocumentProcessor::toTextEditorSelect
QTextCursor c(textDocument->findBlockByNumber(m.line() - 1));
const QString text = c.block().text();
if (m.length() > 0 && m.column() + m.length() < (unsigned)text.size()) {
int column = m.column() > 0 ? m.column() - 1 : 0;
c.setPosition(c.position() + column);
const int startPos = m.column() > 0 ? m.column() - 1 : 0;
if (m.length() > 0 && startPos + m.length() <= (unsigned)text.size()) {
c.setPosition(c.position() + startPos);
c.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, m.length());
} else {
for (int i = 0; i < text.size(); ++i) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment