forked from qt-creator/qt-creator
Editor: Prevent setting negative position in block selection
Fixes: QTCREATORBUG-23622 Change-Id: I0f041a772869695e7d460effd4b0d58f94ce55ec Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -5466,7 +5466,7 @@ void TextEditorWidget::mouseMoveEvent(QMouseEvent *e)
|
|||||||
column += (e->pos().x() - cursorRect().center().x()) / QFontMetricsF(font()).horizontalAdvance(QLatin1Char(' '));
|
column += (e->pos().x() - cursorRect().center().x()) / QFontMetricsF(font()).horizontalAdvance(QLatin1Char(' '));
|
||||||
|
|
||||||
d->m_blockSelection.positionBlock = cursor.blockNumber();
|
d->m_blockSelection.positionBlock = cursor.blockNumber();
|
||||||
d->m_blockSelection.positionColumn = column;
|
d->m_blockSelection.positionColumn = qMax(0, column);
|
||||||
|
|
||||||
doSetTextCursor(d->m_blockSelection.selection(d->m_document.data()), true);
|
doSetTextCursor(d->m_blockSelection.selection(d->m_document.data()), true);
|
||||||
viewport()->update();
|
viewport()->update();
|
||||||
@@ -8035,12 +8035,12 @@ QTextCursor TextBlockSelection::cursor(const TextDocument *baseTextDocument,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TextBlockSelection::fromPostition(int positionBlock, int positionColumn,
|
void TextBlockSelection::fromPostition(int positionBlock, int positionColumn,
|
||||||
int anchorBlock, int anchorColumn)
|
int anchorBlock, int anchorColumn)
|
||||||
{
|
{
|
||||||
this->positionBlock = positionBlock;
|
this->positionBlock = QTC_GUARD(positionBlock >= 0) ? positionBlock : 0;
|
||||||
this->positionColumn = positionColumn;
|
this->positionColumn = QTC_GUARD(positionColumn >= 0) ? positionColumn : 0;
|
||||||
this->anchorBlock = anchorBlock;
|
this->anchorBlock = QTC_GUARD(anchorBlock >= 0) ? anchorBlock : 0;
|
||||||
this->anchorColumn = anchorColumn;
|
this->anchorColumn = QTC_GUARD(anchorColumn >= 0) ? anchorColumn : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextEditorWidget::inFindScope(const QTextCursor &cursor)
|
bool TextEditorWidget::inFindScope(const QTextCursor &cursor)
|
||||||
|
Reference in New Issue
Block a user