forked from qt-creator/qt-creator
Editor: Skip auto inserted characters with tab
Fixes: QTCREATORBUG-12641 Change-Id: I9800b939118d1e46d202454a66729cd81d2c08b3 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user