File tree Expand file tree Collapse file tree 1 file changed +20
-14
lines changed Expand file tree Collapse file tree 1 file changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -230,20 +230,26 @@ class InMemoryPackageIndex {
230230
231231 String ? bestNameMatch;
232232 if (parsedQueryText != null ) {
233- final matches = _packageNameIndex.lookupMatchingNames (parsedQueryText);
234- if (matches != null && matches.isNotEmpty) {
235- bestNameMatch = matches.length == 1
236- ? matches.single
237- :
238- // Note: to keep it simple, we select the most downloaded one from competing matches.
239- matches.reduce ((a, b) {
240- if (_documentsByName[a]! .downloadCount >
241- _documentsByName[b]! .downloadCount) {
242- return a;
243- } else {
244- return b;
245- }
246- });
233+ // exact package name
234+ if (_documentsByName.containsKey (parsedQueryText)) {
235+ bestNameMatch = parsedQueryText;
236+ } else {
237+ // reduced package name match
238+ final matches = _packageNameIndex.lookupMatchingNames (parsedQueryText);
239+ if (matches != null && matches.isNotEmpty) {
240+ bestNameMatch = matches.length == 1
241+ ? matches.single
242+ :
243+ // Note: to keep it simple, we select the most downloaded one from competing matches.
244+ matches.reduce ((a, b) {
245+ if (_documentsByName[a]! .downloadCount >
246+ _documentsByName[b]! .downloadCount) {
247+ return a;
248+ } else {
249+ return b;
250+ }
251+ });
252+ }
247253 }
248254 }
249255
You can’t perform that action at this time.
0 commit comments