diff --git a/src/plugins/texteditor/completionsettingspage.ui b/src/plugins/texteditor/completionsettingspage.ui index c661f531ee9..16d1fc47ec5 100644 --- a/src/plugins/texteditor/completionsettingspage.ui +++ b/src/plugins/texteditor/completionsettingspage.ui @@ -318,7 +318,7 @@ In addition, Shift+Enter inserts an escape character at the cursor position and - Skip automatically inserted character if re-typed manually after completion. + Skip automatically inserted character if re-typed manually after completion or by pressing tab. Skip automatically inserted character when typing diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 97978476a25..283f2155574 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -2484,6 +2484,21 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *e) return; } QTextCursor cursor = textCursor(); + if (d->m_skipAutoCompletedText && e->key() == Qt::Key_Tab) { + bool skippedAutoCompletedText = false; + while (!d->m_autoCompleteHighlightPos.isEmpty() + && d->m_autoCompleteHighlightPos.last().selectionStart() == cursor.position()) { + skippedAutoCompletedText = true; + cursor.setPosition(d->m_autoCompleteHighlightPos.last().selectionEnd()); + d->m_autoCompleteHighlightPos.pop_back(); + } + if (skippedAutoCompletedText) { + setTextCursor(cursor); + e->accept(); + d->updateAutoCompleteHighlight(); + return; + } + } int newPosition; if (d->m_document->typingSettings().tabShouldIndent(document(), cursor, &newPosition)) { if (newPosition != cursor.position() && !cursor.hasSelection()) {