Skip to content

Commit 6ab72e3

Browse files
committed
Different label for exact match.
1 parent 96d2412 commit 6ab72e3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

app/lib/frontend/templates/listing.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ String renderPkgIndexPage(
5050
title: topPackages,
5151
messageFromBackend: searchResultPage.errorMessage,
5252
),
53-
nameMatches: _nameMatches(searchResultPage.nameMatches),
53+
nameMatches: _nameMatches(searchForm, searchResultPage.nameMatches),
5454
packageList: packageList(searchResultPage),
5555
pagination: searchResultPage.hasHit ? paginationNode(links) : null,
5656
openSections: openSections,
@@ -124,14 +124,18 @@ class PageLinks {
124124
}
125125
}
126126

127-
d.Node? _nameMatches(List<String>? matches) {
127+
d.Node? _nameMatches(SearchForm form, List<String>? matches) {
128128
if (matches == null || matches.isEmpty) {
129129
return null;
130130
}
131131
final singular = matches.length == 1;
132-
final namePluralized = singular ? 'name' : 'names';
132+
final isExactNameMatch = singular && form.parsedQuery.text == matches.single;
133+
final nameMatchLabel = isExactNameMatch
134+
? 'Exact package name match: '
135+
: 'Matching package ${singular ? 'name' : 'names'}: ';
136+
133137
return d.p(children: [
134-
d.b(text: 'Matching package $namePluralized: '),
138+
d.b(text: nameMatchLabel),
135139
...matches.expandIndexed((i, name) {
136140
return [
137141
if (i > 0) d.text(', '),

0 commit comments

Comments
 (0)