forked from qt-creator/qt-creator
Don't move cursor on collapse/uncollapse
When the cursor isn't within the block that's being collapsed, it shouldn't be moved. When it is, it will now move upwards instead of to the start of the line. Reviewed-by: mae
This commit is contained in:
@@ -2504,14 +2504,13 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick) {
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
if (d->m_codeFoldingVisible && TextBlockUserData::canCollapse(cursor.block())
|
||||
&& !TextBlockUserData::hasClosingCollapseInside(cursor.block().next())
|
||||
&& collapseBox(cursor.block()).contains(e->pos())) {
|
||||
setTextCursor(cursor);
|
||||
toggleBlockVisible(cursor.block());
|
||||
d->moveCursorVisible(false);
|
||||
} else if (d->m_marksVisible && e->pos().x() > markWidth) {
|
||||
QTextCursor selection = cursor;
|
||||
selection.setVisualNavigation(true);
|
||||
@@ -3392,14 +3391,15 @@ void BaseTextEditor::setIfdefedOutBlocks(const QList<BaseTextEditor::BlockRange>
|
||||
}
|
||||
|
||||
|
||||
void BaseTextEditorPrivate::moveCursorVisible()
|
||||
void BaseTextEditorPrivate::moveCursorVisible(bool ensureVisible)
|
||||
{
|
||||
QTextCursor cursor = q->textCursor();
|
||||
if (!cursor.block().isVisible()) {
|
||||
cursor.setVisualNavigation(true);
|
||||
cursor.movePosition(QTextCursor::PreviousBlock);
|
||||
cursor.movePosition(QTextCursor::Up);
|
||||
q->setTextCursor(cursor);
|
||||
}
|
||||
if (ensureVisible)
|
||||
q->ensureCursorVisible();
|
||||
}
|
||||
|
||||
|
@@ -218,7 +218,7 @@ public:
|
||||
QTextCursor m_findScope;
|
||||
QTextCursor m_selectBlockAnchor;
|
||||
|
||||
void moveCursorVisible();
|
||||
void moveCursorVisible(bool ensureVisible = true);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user