From c8ef91f7892c3c12ddd92d7ca5b4bdc9936c7f07 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Wed, 15 Jun 2016 07:56:24 +0200 Subject: Revert "TextEditor: Do not delete both quotes on backspace" We have a more intelligent placing of double quotes, that should eliminate some of the incorrect/unwanted placed closing quotes. Additionally we introduced an animation and highlight of automatically inserted text. So it should be definitely clear that the closing quote is going to be removed. If there is still someone who gets annoyed by this reintroduced behavior there is now a setting that lets you control the deletion of automatically inserted text. So it is safe to reintroduce the deletion of closing quotes on backspace. This reverts commit 4a0b2039c0ed5c1f34efaf8f53dcf04ad9f384df. Change-Id: I92500ac218dc4c2e07a3b0ad01b06e6baa2e2c6c Reviewed-by: Eike Ziller --- src/plugins/texteditor/autocompleter.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/texteditor/autocompleter.cpp b/src/plugins/texteditor/autocompleter.cpp index 1cc4a9ee56..4a5d502801 100644 --- a/src/plugins/texteditor/autocompleter.cpp +++ b/src/plugins/texteditor/autocompleter.cpp @@ -212,6 +212,7 @@ bool AutoCompleter::autoBackspace(QTextCursor &cursor) QTextDocument *doc = cursor.document(); const QChar lookAhead = doc->characterAt(pos); const QChar lookBehind = doc->characterAt(pos - 1); + const QChar lookFurtherBehind = doc->characterAt(pos - 2); const QChar character = lookBehind; if (character == QLatin1Char('(') || character == QLatin1Char('[')) { @@ -240,7 +241,11 @@ bool AutoCompleter::autoBackspace(QTextCursor &cursor) // ### this code needs to be generalized if ((lookBehind == QLatin1Char('(') && lookAhead == QLatin1Char(')')) - || (lookBehind == QLatin1Char('[') && lookAhead == QLatin1Char(']'))) { + || (lookBehind == QLatin1Char('[') && lookAhead == QLatin1Char(']')) + || (lookBehind == QLatin1Char('"') && lookAhead == QLatin1Char('"') + && lookFurtherBehind != QLatin1Char('\\')) + || (lookBehind == QLatin1Char('\'') && lookAhead == QLatin1Char('\'') + && lookFurtherBehind != QLatin1Char('\\'))) { if (! isInComment(c)) { cursor.beginEditBlock(); cursor.deleteChar(); -- cgit v1.2.1