diff options
author | David Schulz <david.schulz@qt.io> | 2016-06-15 07:56:24 +0200 |
---|---|---|
committer | David Schulz <david.schulz@theqtcompany.com> | 2016-06-22 12:50:36 +0000 |
commit | c8ef91f7892c3c12ddd92d7ca5b4bdc9936c7f07 (patch) | |
tree | e6ae8b3837fa3beb0890fa1996bb942e1e84a128 | |
parent | eba6da37c65488f86c60ce3970f13b2b143c2a5a (diff) | |
download | qt-creator-c8ef91f7892c3c12ddd92d7ca5b4bdc9936c7f07.tar.gz |
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 <eike.ziller@qt.io>
-rw-r--r-- | src/plugins/texteditor/autocompleter.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
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(); |