diff options
author | Francois Ferrand <thetypz@gmail.com> | 2014-10-16 10:18:48 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2014-10-23 10:51:54 +0200 |
commit | acf79d7fc61bdaefd2b108902b85f4ab48653bbe (patch) | |
tree | 8329349d1db39ca4adb32ef6f7c1ca01978b8181 /src/plugins/cpptools/baseeditordocumentprocessor.cpp | |
parent | 4b44d2c6c52d2ad669a53470f06b104a29e72c24 (diff) |
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: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Diffstat (limited to 'src/plugins/cpptools/baseeditordocumentprocessor.cpp')
-rw-r--r-- | src/plugins/cpptools/baseeditordocumentprocessor.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/plugins/cpptools/baseeditordocumentprocessor.cpp b/src/plugins/cpptools/baseeditordocumentprocessor.cpp index 30a3e7937ff..816b9375863 100644 --- a/src/plugins/cpptools/baseeditordocumentprocessor.cpp +++ b/src/plugins/cpptools/baseeditordocumentprocessor.cpp @@ -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) { |