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:
@@ -81,6 +81,8 @@ QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterfac
|
||||
m_itemsOfCurrentDoc = search(thisDocument);
|
||||
}
|
||||
|
||||
const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
|
||||
|
||||
foreach (const ModelItemInfo & info, m_itemsOfCurrentDoc)
|
||||
{
|
||||
if (future.isCanceled())
|
||||
@@ -94,7 +96,7 @@ QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterfac
|
||||
Locator::FilterEntry filterEntry(this, symbolName, id, info.icon);
|
||||
filterEntry.extraInfo = info.symbolType;
|
||||
|
||||
if (info.symbolName.startsWith(entry))
|
||||
if (info.symbolName.startsWith(entry, caseSensitivityForPrefix))
|
||||
betterEntries.append(filterEntry);
|
||||
else
|
||||
goodEntries.append(filterEntry);
|
||||
|
||||
@@ -135,6 +135,7 @@ QList<Locator::FilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Locato
|
||||
if (!regexp.isValid())
|
||||
return goodEntries;
|
||||
bool hasWildcard = (entry.contains(asterisk) || entry.contains(QLatin1Char('?')));
|
||||
const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
|
||||
|
||||
QHashIterator<QString, QList<ModelItemInfo> > it(m_searchList);
|
||||
while (it.hasNext()) {
|
||||
@@ -157,7 +158,7 @@ QList<Locator::FilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Locato
|
||||
FileName::fromString(info.fileName));
|
||||
}
|
||||
|
||||
if (info.symbolName.startsWith(entry))
|
||||
if (info.symbolName.startsWith(entry, caseSensitivityForPrefix))
|
||||
betterEntries.append(filterEntry);
|
||||
else
|
||||
goodEntries.append(filterEntry);
|
||||
|
||||
@@ -195,12 +195,12 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
|
||||
<< cppLocatorFilter
|
||||
<< _("myclass")
|
||||
<< (QList<ResultData>()
|
||||
<< ResultData(_("<anonymous namespace>::MyClass"), testFileShort)
|
||||
<< ResultData(_("<anonymous namespace>::MyClass::MyClass"), _("()"))
|
||||
<< ResultData(_("<anonymous namespace>::MyClass::function2"), _("(bool, int)"))
|
||||
<< ResultData(_("MyClass"), testFileShort)
|
||||
<< ResultData(_("MyClass::MyClass"), _("()"))
|
||||
<< ResultData(_("MyClass::function2"), _("(bool, int)"))
|
||||
<< ResultData(_("<anonymous namespace>::MyClass"), testFileShort)
|
||||
<< ResultData(_("<anonymous namespace>::MyClass::MyClass"), _("()"))
|
||||
<< ResultData(_("<anonymous namespace>::MyClass::function2"), _("(bool, int)"))
|
||||
<< ResultData(_("MyNamespace::MyClass"), testFileShort)
|
||||
<< ResultData(_("MyNamespace::MyClass::MyClass"), _("()"))
|
||||
<< ResultData(_("MyNamespace::MyClass::function2"), _("(bool, int)"))
|
||||
|
||||
Reference in New Issue
Block a user