From 961fe9ed8ae2ee6143d8b47b52ddf8f4242ce486 Mon Sep 17 00:00:00 2001 From: mae <qt-info@nokia.com> Date: Mon, 5 Oct 2009 15:17:24 +0200 Subject: [PATCH] Fix QKeySequence::DeleteStartOfWord in auto-indentation mode The changes enables the auto-parentheses magic of normal backspace also for the DeleteStartOfWord case. --- src/plugins/texteditor/basetexteditor.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 235120ba4bd..99c18a9bb37 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -962,6 +962,23 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e) return; } } + } else if (!ro + && e == QKeySequence::DeleteStartOfWord + && d->m_document->tabSettings().m_autoIndent + && !textCursor().hasSelection()){ + e->accept(); + QTextCursor c = textCursor(); + int pos = c.position(); + c.movePosition(QTextCursor::PreviousWord); + int targetpos = c.position(); + forever { + handleBackspaceKey(); + int cpos = textCursor().position(); + if (cpos == pos || cpos <= targetpos) + break; + pos = cpos; + } + return; } else switch (e->key()) { @@ -3289,7 +3306,7 @@ void BaseTextEditor::handleBackspaceKey() const TextEditor::TabSettings &tabSettings = d->m_document->tabSettings(); - if (autoBackspace(cursor)) + if (tabSettings.m_autoIndent && autoBackspace(cursor)) return; if (!tabSettings.m_smartBackspace) { -- GitLab