From 9ff527e2aa34cd97cdf5b9301380dd91355f2857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= <thorbjorn.lindeijer@nokia.com> Date: Wed, 16 Sep 2009 16:28:32 +0200 Subject: [PATCH] Check context when removing matching parentheses Done with mae. --- src/plugins/texteditor/basetexteditor.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 27ecdb3206a..06603180181 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -3272,12 +3272,18 @@ void BaseTextEditor::handleBackspaceKey() if ((lookBehind == QLatin1Char('(') && lookAhead == QLatin1Char(')')) || (lookBehind == QLatin1Char('[') && lookAhead == QLatin1Char(']')) || (lookBehind == QLatin1Char('"') && lookAhead == QLatin1Char('"') - && lookFurtherBehind!= QLatin1Char('\\'))) { - cursor.beginEditBlock(); - cursor.deleteChar(); - cursor.deletePreviousChar(); - cursor.endEditBlock(); - return; + && lookFurtherBehind != QLatin1Char('\\')) + || (lookBehind == QLatin1Char('\'') && lookAhead == QLatin1Char('\'') + && lookFurtherBehind != QLatin1Char('\\'))) { + QTextCursor c = cursor; + c.setPosition(pos - 1); + if (contextAllowsAutoParentheses(c)) { + cursor.beginEditBlock(); + cursor.deleteChar(); + cursor.deletePreviousChar(); + cursor.endEditBlock(); + return; + } } } -- GitLab