Commit cbcc2e51 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

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
parent b6c15d1b
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment