Commit 4a0b2039 authored by Nikolai Kosjar's avatar Nikolai Kosjar

TextEditor: Do not delete both quotes on backspace

...if cursor is in-between.

Hitting backspace when the cursor is between two quotes

    "|"

deleted both quotes, which is unfavorable, especially when the user
tries to add quotes by starting with the closing quote.

Task-number: QTCREATORBUG-14111
Change-Id: I8f08f355e34fba1b517dad9864944cb11ff5c1c2
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent 7dc2cb9d
......@@ -208,7 +208,6 @@ 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('[')) {
......@@ -237,11 +236,7 @@ bool AutoCompleter::autoBackspace(QTextCursor &cursor)
// ### this code needs to be generalized
if ((lookBehind == QLatin1Char('(') && lookAhead == QLatin1Char(')'))
|| (lookBehind == QLatin1Char('[') && lookAhead == QLatin1Char(']'))
|| (lookBehind == QLatin1Char('"') && lookAhead == QLatin1Char('"')
&& lookFurtherBehind != QLatin1Char('\\'))
|| (lookBehind == QLatin1Char('\'') && lookAhead == QLatin1Char('\'')
&& lookFurtherBehind != QLatin1Char('\\'))) {
|| (lookBehind == QLatin1Char('[') && lookAhead == QLatin1Char(']'))) {
if (! isInComment(c)) {
cursor.beginEditBlock();
cursor.deleteChar();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment