Commit 9cf40745 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer

Added option to disable completion of common prefix

Some people don't like this.
parent e19c940d
......@@ -69,6 +69,7 @@ QWidget *CompletionSettingsPage::createPage(QWidget *parent)
m_page->caseSensitive->setChecked(m_completion->caseSensitivity() == Qt::CaseSensitive);
m_page->autoInsertBraces->setChecked(m_completion->autoInsertBraces());
m_page->partiallyComplete->setChecked(m_completion->isPartialCompletionEnabled());
return w;
}
......@@ -79,6 +80,7 @@ void CompletionSettingsPage::finished(bool accepted)
m_completion->setCaseSensitivity(
m_page->caseSensitive->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive);
m_completion->setAutoInsertBraces(m_page->autoInsertBraces->isChecked());
m_completion->setPartialCompletionEnabled(m_page->partiallyComplete->isChecked());
}
delete m_page;
......
......@@ -17,7 +17,7 @@
<item>
<widget class="QCheckBox" name="caseSensitive">
<property name="text">
<string>Match completions &amp;case-sensitive</string>
<string>&amp;Case-sensitive completion</string>
</property>
<property name="checked">
<bool>true</bool>
......@@ -34,6 +34,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="partiallyComplete">
<property name="text">
<string>Autocomplete common &amp;prefix</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
......
......@@ -346,6 +346,16 @@ void CppCodeCompletion::setAutoInsertBraces(bool autoInsertBraces)
m_autoInsertBraces = autoInsertBraces;
}
bool CppCodeCompletion::isPartialCompletionEnabled() const
{
return m_partialCompletionEnabled;
}
void CppCodeCompletion::setPartialCompletionEnabled(bool partialCompletionEnabled)
{
m_partialCompletionEnabled = partialCompletionEnabled;
}
/*
Searches beckward for an access operator.
*/
......@@ -1030,7 +1040,7 @@ bool CppCodeCompletion::partiallyComplete(const QList<TextEditor::CompletionItem
} else if (completionItems.count() == 1) {
complete(completionItems.first());
return true;
} else if (m_completionOperator != T_LPAREN) {
} else if (m_partialCompletionEnabled && m_completionOperator != T_LPAREN) {
// Compute common prefix
QString firstKey = completionItems.first().m_text;
QString lastKey = completionItems.last().m_text;
......
......@@ -84,6 +84,9 @@ public:
bool autoInsertBraces() const;
void setAutoInsertBraces(bool autoInsertBraces);
bool isPartialCompletionEnabled() const;
void setPartialCompletionEnabled(bool partialCompletionEnabled);
private:
void addKeywords();
void addMacros(const CPlusPlus::LookupContext &context);
......@@ -134,6 +137,7 @@ private:
CppModelManager *m_manager;
Qt::CaseSensitivity m_caseSensitivity;
bool m_autoInsertBraces;
bool m_partialCompletionEnabled;
bool m_forcedCompletion;
......
......@@ -120,6 +120,7 @@ bool CppToolsPlugin::initialize(const QStringList & /*arguments*/, QString *)
const bool caseSensitive = settings->value(QLatin1String("CaseSensitive"), true).toBool();
m_completion->setCaseSensitivity(caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
m_completion->setAutoInsertBraces(settings->value(QLatin1String("AutoInsertBraces"), true).toBool());
m_completion->setPartialCompletionEnabled(settings->value(QLatin1String("PartiallyComplete"), true).toBool());
settings->endGroup();
settings->endGroup();
......@@ -138,6 +139,7 @@ void CppToolsPlugin::shutdown()
settings->beginGroup(QLatin1String("Completion"));
settings->setValue(QLatin1String("CaseSensitive"), m_completion->caseSensitivity() == Qt::CaseSensitive);
settings->setValue(QLatin1String("AutoInsertBraces"), m_completion->autoInsertBraces());
settings->setValue(QLatin1String("PartiallyComplete"), m_completion->isPartialCompletionEnabled());
settings->endGroup();
settings->endGroup();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment