diff --git a/src/plugins/texteditor/completionsettings.cpp b/src/plugins/texteditor/completionsettings.cpp
index a012e407c2f..61c9f203a87 100644
--- a/src/plugins/texteditor/completionsettings.cpp
+++ b/src/plugins/texteditor/completionsettings.cpp
@@ -41,6 +41,7 @@ static const char autoSplitStringsKey[] = "AutoSplitStrings";
static const char animateAutoCompleteKey[] = "AnimateAutoComplete";
static const char highlightAutoCompleteKey[] = "HighlightAutoComplete";
static const char skipAutoCompleteKey[] = "SkipAutoComplete";
+static const char autoRemoveKey[] = "AutoRemove";
using namespace TextEditor;
@@ -60,6 +61,7 @@ void CompletionSettings::toSettings(QSettings *s) const
s->setValue(animateAutoCompleteKey, m_animateAutoComplete);
s->setValue(highlightAutoCompleteKey, m_highlightAutoComplete);
s->setValue(skipAutoCompleteKey, m_skipAutoCompletedText);
+ s->setValue(autoRemoveKey, m_autoRemove);
s->endGroup();
}
@@ -94,6 +96,8 @@ void CompletionSettings::fromSettings(QSettings *s)
s->value(highlightAutoCompleteKey, m_highlightAutoComplete).toBool();
m_skipAutoCompletedText =
s->value(skipAutoCompleteKey, m_skipAutoCompletedText).toBool();
+ m_autoRemove =
+ s->value(autoRemoveKey, m_autoRemove).toBool();
s->endGroup();
}
@@ -112,5 +116,6 @@ bool CompletionSettings::equals(const CompletionSettings &cs) const
&& m_animateAutoComplete == cs.m_animateAutoComplete
&& m_highlightAutoComplete == cs.m_highlightAutoComplete
&& m_skipAutoCompletedText == cs.m_skipAutoCompletedText
+ && m_autoRemove == cs.m_autoRemove
;
}
diff --git a/src/plugins/texteditor/completionsettings.h b/src/plugins/texteditor/completionsettings.h
index 7ca5535b3eb..9fa75e6152f 100644
--- a/src/plugins/texteditor/completionsettings.h
+++ b/src/plugins/texteditor/completionsettings.h
@@ -69,6 +69,7 @@ public:
bool m_animateAutoComplete = true;
bool m_highlightAutoComplete = true;
bool m_skipAutoCompletedText = true;
+ bool m_autoRemove = true;
};
inline bool operator==(const CompletionSettings &t1, const CompletionSettings &t2) { return t1.equals(t2); }
diff --git a/src/plugins/texteditor/completionsettingspage.cpp b/src/plugins/texteditor/completionsettingspage.cpp
index 1c5d4e2ddea..b824926028d 100644
--- a/src/plugins/texteditor/completionsettingspage.cpp
+++ b/src/plugins/texteditor/completionsettingspage.cpp
@@ -105,6 +105,7 @@ QWidget *CompletionSettingsPage::widget()
m_page->animateAutoComplete->setChecked(m_completionSettings.m_animateAutoComplete);
m_page->highlightAutoComplete->setChecked(m_completionSettings.m_highlightAutoComplete);
m_page->skipAutoComplete->setChecked(m_completionSettings.m_skipAutoCompletedText);
+ m_page->removeAutoComplete->setChecked(m_completionSettings.m_autoRemove);
m_page->enableDoxygenCheckBox->setChecked(m_commentsSettings.m_enableDoxygen);
m_page->generateBriefCheckBox->setChecked(m_commentsSettings.m_generateBrief);
@@ -112,6 +113,7 @@ QWidget *CompletionSettingsPage::widget()
m_page->generateBriefCheckBox->setEnabled(m_page->enableDoxygenCheckBox->isChecked());
m_page->skipAutoComplete->setEnabled(m_page->highlightAutoComplete->isChecked());
+ m_page->removeAutoComplete->setEnabled(m_page->highlightAutoComplete->isChecked());
}
return m_widget;
}
@@ -182,6 +184,7 @@ void CompletionSettingsPage::settingsFromUi(CompletionSettings &completion, Comm
completion.m_animateAutoComplete = m_page->animateAutoComplete->isChecked();
completion.m_highlightAutoComplete = m_page->highlightAutoComplete->isChecked();
completion.m_skipAutoCompletedText = m_page->skipAutoComplete->isChecked();
+ completion.m_autoRemove = m_page->removeAutoComplete->isChecked();
comment.m_enableDoxygen = m_page->enableDoxygenCheckBox->isChecked();
comment.m_generateBrief = m_page->generateBriefCheckBox->isChecked();
diff --git a/src/plugins/texteditor/completionsettingspage.ui b/src/plugins/texteditor/completionsettingspage.ui
index b5bf12a0a0e..7eda07d2aed 100644
--- a/src/plugins/texteditor/completionsettingspage.ui
+++ b/src/plugins/texteditor/completionsettingspage.ui
@@ -7,7 +7,7 @@
0
0
551
- 465
+ 493
@@ -270,6 +270,39 @@ In addition, Shift+Enter inserts an escape character at the cursor position and
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 30
+ 20
+
+
+
+
+ -
+
+
+ Remove the automatically inserted character if the trigger is deleted by backspace after the completion.
+
+
+ Remove automatically inserted text on backspace
+
+
+ true
+
+
+
+
+
@@ -361,6 +394,7 @@ In addition, Shift+Enter inserts an escape character at the cursor position and
animateAutoComplete
highlightAutoComplete
skipAutoComplete
+ removeAutoComplete
enableDoxygenCheckBox
generateBriefCheckBox
leadingAsterisksCheckBox
@@ -374,12 +408,12 @@ In addition, Shift+Enter inserts an escape character at the cursor position and
setEnabled(bool)
- 195
- 383
+ 216
+ 411
- 320
- 410
+ 378
+ 438
@@ -399,5 +433,21 @@ In addition, Shift+Enter inserts an escape character at the cursor position and
+
+ highlightAutoComplete
+ toggled(bool)
+ removeAutoComplete
+ setEnabled(bool)
+
+
+ 223
+ 275
+
+
+ 226
+ 333
+
+
+
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index 5f0ecb647b3..70e70585890 100644
--- a/src/plugins/texteditor/texteditor.cpp
+++ b/src/plugins/texteditor/texteditor.cpp
@@ -456,6 +456,7 @@ public:
bool m_animateAutoComplete = true;
bool m_highlightAutoComplete = true;
bool m_skipAutoCompletedText = true;
+ bool m_removeAutoCompletedText = true;
bool m_keepAutoCompletionHighlight = false;
QTextCursor m_autoCompleteHighlightPos;
@@ -5365,8 +5366,10 @@ void TextEditorWidgetPrivate::handleBackspaceKey()
const TabSettings &tabSettings = m_document->tabSettings();
const TypingSettings &typingSettings = m_document->typingSettings();
- if (typingSettings.m_autoIndent && m_autoCompleter->autoBackspace(cursor))
+ if (typingSettings.m_autoIndent && (m_autoCompleteHighlightPos == cursor)
+ && m_removeAutoCompletedText && m_autoCompleter->autoBackspace(cursor)) {
return;
+ }
bool handled = false;
if (typingSettings.m_smartBackspaceBehavior == TypingSettings::BackspaceNeverIndents) {
@@ -6571,6 +6574,7 @@ void TextEditorWidget::setCompletionSettings(const CompletionSettings &completio
d->m_animateAutoComplete = completionSettings.m_animateAutoComplete;
d->m_highlightAutoComplete = completionSettings.m_highlightAutoComplete;
d->m_skipAutoCompletedText = completionSettings.m_skipAutoCompletedText;
+ d->m_removeAutoCompletedText = completionSettings.m_autoRemove;
}
void TextEditorWidget::setExtraEncodingSettings(const ExtraEncodingSettings &extraEncodingSettings)