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:
@@ -318,7 +318,7 @@ In addition, Shift+Enter inserts an escape character at the cursor position and
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="skipAutoComplete">
|
<widget class="QCheckBox" name="skipAutoComplete">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Skip automatically inserted character if re-typed manually after completion.</string>
|
<string>Skip automatically inserted character if re-typed manually after completion or by pressing tab.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Skip automatically inserted character when typing</string>
|
<string>Skip automatically inserted character when typing</string>
|
||||||
|
@@ -2484,6 +2484,21 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *e)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QTextCursor cursor = textCursor();
|
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;
|
int newPosition;
|
||||||
if (d->m_document->typingSettings().tabShouldIndent(document(), cursor, &newPosition)) {
|
if (d->m_document->typingSettings().tabShouldIndent(document(), cursor, &newPosition)) {
|
||||||
if (newPosition != cursor.position() && !cursor.hasSelection()) {
|
if (newPosition != cursor.position() && !cursor.hasSelection()) {
|
||||||
|
Reference in New Issue
Block a user