forked from qt-creator/qt-creator
Utils: make select at column 0-based
Change-Id: I514611cbd887eec6e46c80e5a2964c04ad05fdf2 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -139,10 +139,10 @@ QTextCursor selectAt(QTextCursor textCursor, int line, int column, uint length)
|
||||
if (line < 1)
|
||||
line = 1;
|
||||
|
||||
if (column < 1)
|
||||
column = 1;
|
||||
if (column < 0)
|
||||
column = 0;
|
||||
|
||||
const int anchorPosition = positionInText(textCursor.document(), line, column);
|
||||
const int anchorPosition = positionInText(textCursor.document(), line, column + 1);
|
||||
textCursor.setPosition(anchorPosition);
|
||||
textCursor.setPosition(anchorPosition + int(length), QTextCursor::KeepAnchor);
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ QTCREATOR_UTILS_EXPORT int positionInText(const QTextDocument *textDocument, int
|
||||
|
||||
QTCREATOR_UTILS_EXPORT QString textAt(QTextCursor tc, int pos, int length);
|
||||
|
||||
// line is 1-based, column is 0-based
|
||||
QTCREATOR_UTILS_EXPORT QTextCursor selectAt(QTextCursor textCursor, int line, int column, uint length);
|
||||
|
||||
QTCREATOR_UTILS_EXPORT QTextCursor flippedCursor(const QTextCursor &cursor);
|
||||
|
||||
@@ -816,7 +816,7 @@ QList<QTextEdit::ExtraSelection> sourceLocationsToExtraSelections(
|
||||
|
||||
selection.cursor = selectAt(cppEditorWidget->textCursor(),
|
||||
sourceLocation.targetLine,
|
||||
sourceLocation.targetColumn + 1,
|
||||
sourceLocation.targetColumn,
|
||||
selectionLength);
|
||||
selection.format = textCharFormat;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user