Commit cf204d6198

cf204d619885d90be8de0571860b1e961e82561b

parent: 4f0b6274b6

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-22 04:40 UTC

web: an empty search says what to do next

The head printed "0 results for <q>" and the body printed "no matches
for <q>" under it: the same fact twice, with no way on. The note now
carries fewer words, the same query across every kind, and the listing.

Closes #248
e2e/searchweb_test.go +11
@@ -56,6 +56,17 @@ func TestGlobalSearchAndNotificationsWeb(t *testing.T) {
5656 t.Fatal("short query not refused")
5757 }
5858
59 // A query that matches nothing says what to do next instead of
60 // repeating the count line's "no matches" under it (#248).
61 _, body = inst.get(t, "/search?q=zzznothing&kind=issue")
62 if !strings.Contains(body, "0 results") || !strings.Contains(body, "Try fewer words") ||
63 !strings.Contains(body, "search everything") {
64 t.Fatalf("empty search lacks its recovery line:\n%s", body)
65 }
66 if strings.Contains(body, "no matches") {
67 t.Fatalf("empty search repeats the count line:\n%s", body)
68 }
69
5970 // Alice sees her private repository and its issue in the same page.
6071 browser := inst.login(t, aliceKey)
6172 status, body = browserGet(t, browser, inst.base()+"/search?q=widget")
internal/web/templates/globalsearch.html +3 −1
@@ -40,7 +40,9 @@
4040</li>
4141{{end}}
4242</ul>
43{{else}}<p class="empty-note">no matches for “{{.Query}}”</p>{{end}}
43{{/* The count line above already says nothing matched, so this one
44 carries the way out instead of repeating it. */}}
45{{else}}<p class="empty-note">Try fewer words{{if .Kind}}, <a href="?q={{.Query}}">search everything</a>,{{end}} or <a href="/explore">browse the repositories</a>.</p>{{end}}
4446{{else}}
4547<p class="empty-note">Repository names, descriptions and topics, and the title and body of every issue and merge request you can read. File contents are searched per repository, from a repository's Code tab.</p>
4648{{end}}