forked from qt-creator/qt-creator
Locator: Case sensitivity of input affects prioritizing
So far candidates were prefix matched case sensitive which led to
an unfavorable results order.
With this patch, if the input is lower case, the prioritizing happens by
a case insensitive prefix match. Otherwise the match happens case
sensitive (just like before).
Example:
Search for e.g. "m cppmodelmanager"
Top result before: AbstractEditorSupport (match at parameter type)
Top result now: CppModelManager
Change-Id: Ic27042cfe717be812a2237a3437399597c98dd74
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
@@ -55,7 +55,10 @@ MacroLocatorFilter::~MacroLocatorFilter()
|
||||
QList<Locator::FilterEntry> MacroLocatorFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry)
|
||||
{
|
||||
Q_UNUSED(future)
|
||||
QList<Locator::FilterEntry> result;
|
||||
QList<Locator::FilterEntry> goodEntries;
|
||||
QList<Locator::FilterEntry> betterEntries;
|
||||
|
||||
const Qt::CaseSensitivity caseSensitivity_ = caseSensitivity(entry);
|
||||
|
||||
const QMap<QString, Macro*> ¯os = MacroManager::macros();
|
||||
QMapIterator<QString, Macro*> it(macros);
|
||||
@@ -64,14 +67,21 @@ QList<Locator::FilterEntry> MacroLocatorFilter::matchesFor(QFutureInterface<Loca
|
||||
it.next();
|
||||
QString name = it.key();
|
||||
|
||||
if (name.contains(entry)) {
|
||||
QList<Locator::FilterEntry> *category = 0;
|
||||
if (name.startsWith(entry, caseSensitivity_))
|
||||
category = &betterEntries;
|
||||
else if (name.contains(entry, caseSensitivity_))
|
||||
category = &goodEntries;
|
||||
|
||||
if (category) {
|
||||
QVariant id;
|
||||
Locator::FilterEntry entry(this, it.key(), id, m_icon);
|
||||
entry.extraInfo = it.value()->description();
|
||||
result.append(entry);
|
||||
category->append(entry);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
betterEntries.append(goodEntries);
|
||||
return betterEntries;
|
||||
}
|
||||
|
||||
void MacroLocatorFilter::accept(Locator::FilterEntry selection) const
|
||||
|
||||
Reference in New Issue
Block a user