aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2010-06-04 13:39:31 +0200
committerhjk <qtc-committer@nokia.com>2010-06-04 13:42:39 +0200
commitd83dee93850bc2481779db0c75c3634588c201cc (patch)
tree097c9b3c52965da39a995d45f8765f5f1eddeece
parent400e8adfabcc502dbe82330dda87692046378c05 (diff)
Fix cursor positioning for up/down after backspace
Reviewed-by: Roberto Raggi (cherry picked from commit 530016aa2f5e02338d423f0959e1052d02a92173)
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index f04af25b09..d8ef9b1fa7 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -1171,7 +1171,6 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
break;
pos = cpos;
}
- setTextCursor(textCursor()); // make cursor visible
return;
} else switch (e->key()) {
@@ -1215,7 +1214,6 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
| Qt::MetaModifier)) == Qt::NoModifier
&& !textCursor().hasSelection()) {
handleBackspaceKey();
- setTextCursor(textCursor()); // make cursor visible
e->accept();
return;
}
@@ -3722,6 +3720,8 @@ void BaseTextEditor::handleHomeKey(bool anchor)
setTextCursor(cursor);
}
+
+#define SET_AND_RETURN(cursor) setTextCursor(cursor); return // make cursor visible and reset vertical x movement
void BaseTextEditor::handleBackspaceKey()
{
QTextCursor cursor = textCursor();
@@ -3741,7 +3741,7 @@ void BaseTextEditor::handleBackspaceKey()
if (!tabSettings.m_smartBackspace) {
cursor.deletePreviousChar();
- return;
+ SET_AND_RETURN(cursor);
}
QTextBlock currentBlock = cursor.block();
@@ -3749,7 +3749,7 @@ void BaseTextEditor::handleBackspaceKey()
const QString blockText = currentBlock.text();
if (cursor.atBlockStart() || tabSettings.firstNonSpace(blockText) < positionInBlock) {
cursor.deletePreviousChar();
- return;
+ SET_AND_RETURN(cursor);
}
int previousIndent = 0;
@@ -3768,10 +3768,11 @@ void BaseTextEditor::handleBackspaceKey()
cursor.setPosition(currentBlock.position(), QTextCursor::KeepAnchor);
cursor.insertText(tabSettings.indentationString(previousNonEmptyBlockText));
cursor.endEditBlock();
- return;
+ SET_AND_RETURN(cursor);
}
}
cursor.deletePreviousChar();
+ SET_AND_RETURN(cursor);
}
void BaseTextEditor::wheelEvent(QWheelEvent *e)