Completion: Don't propose when there's a "good" candidate

This also generalizes some code previously specific to C++.

Change-Id: I5774d04a45f28a4e276a0ef282ce0aa5a2f2e552
Reviewed-on: http://codereview.qt.nokia.com/48
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
Leandro Melo
2011-05-20 15:01:45 +02:00
committed by Leandro T. C. Melo
parent 1b374905f9
commit 0350314b22
3 changed files with 46 additions and 31 deletions

View File

@@ -698,28 +698,6 @@ IAssistProposal * CppCompletionAssistProcessor::perform(const IAssistInterface *
if (m_hintProposal)
return m_hintProposal;
if (interface->reason() == IdleEditor) {
const int pos = m_interface->position();
const QChar ch = m_interface->characterAt(pos);
if (! (ch.isLetterOrNumber() || ch == QLatin1Char('_'))) {
for (int i = pos - 1;; --i) {
const QChar ch = m_interface->characterAt(i);
if (ch.isLetterOrNumber() || ch == QLatin1Char('_')) {
const QString wordUnderCursor = m_interface->textAt(i, pos - i);
if (wordUnderCursor.at(0).isLetter() || wordUnderCursor.at(0) == QLatin1Char('_')) {
foreach (const BasicProposalItem *item, m_completions) {
if (item->text() == wordUnderCursor)
return 0;
}
} else {
return 0;
}
} else
break;
}
}
}
if (m_model->m_completionOperator != T_EOF_SYMBOL)
m_model->m_sortable = true;
else