From 68d85acaa512c9cdcb33323a3ccf9a2f811a41bf Mon Sep 17 00:00:00 2001 From: mae <qt-info@nokia.com> Date: Wed, 6 May 2009 11:18:56 +0200 Subject: [PATCH] supress parentheses animation if the position was part of the previous parentheses highlighting. This makes the Delete key work smoother when the cursor is positioned behind a closing parenthesis. --- src/plugins/texteditor/basetexteditor.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index d01cc3f1d6e..0918c841548 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -960,7 +960,8 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e) skip_event: if (!ro && e->key() == Qt::Key_Delete && d->m_parenthesesMatchingEnabled) - slotCursorPositionChanged(); // parentheses matching + d->m_parenthesesMatchingTimer->start(50); + if (!ro && d->m_contentsChanged && !e->text().isEmpty() && e->text().at(0).isPrint()) emit requestAutoCompletion(editableInterface(), false); @@ -3535,9 +3536,18 @@ void BaseTextEditor::_q_matchParentheses() } extraSelections.append(sel); } - setExtraSelections(ParenthesesMatchingSelection, extraSelections); + if (animatePosition >= 0) { + foreach (QTextEdit::ExtraSelection sel, BaseTextEditor::extraSelections(ParenthesesMatchingSelection)) { + if (sel.cursor.selectionStart() == animatePosition + || sel.cursor.selectionEnd() - 1 == animatePosition) { + animatePosition = -1; + break; + } + } + } + if (animatePosition >= 0) { if (d->m_animator) d->m_animator->finish(); // one animation is enough @@ -3549,9 +3559,9 @@ void BaseTextEditor::_q_matchParentheses() d->m_animator->setData(font(), pal, characterAt(d->m_animator->position())); connect(d->m_animator, SIGNAL(updateRequest(int,QRectF)), this, SLOT(_q_animateUpdate(int,QRectF))); - } - + } + setExtraSelections(ParenthesesMatchingSelection, extraSelections); } void BaseTextEditor::_q_highlightBlocks() -- GitLab