forked from qt-creator/qt-creator
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: Eike Ziller <eike.ziller@theqtcompany.com> Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user