forked from qt-creator/qt-creator
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>
This commit is contained in:
committed by
Nikolai Kosjar
parent
4b44d2c6c5
commit
acf79d7fc6
@@ -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) {
|
||||
|
Reference in New Issue
Block a user