feat(timezone): let the picker search by abbreviation
Search matched city, id, and the long localized name but not the abbreviation, so typing "CEST" found nothing. Match it too: an exact abbreviation hit ranks just under a city prefix, so typing an abbreviation gathers every zone that shows it (all the CEST zones at once). It matches the region-resolved abbreviation — i.e. exactly what the row displays. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -105,6 +105,19 @@ class TimeZoneCatalogTest {
|
||||
assertThat(filter("europe/berlin").map { it.id }).contains("Europe/Berlin")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `query matches the abbreviation, case-insensitively`() {
|
||||
// "cest" isn't a city, id, or substring of "Central European Summer
|
||||
// Time", so the only way these match is via the abbreviation.
|
||||
val hits = filter("cest")
|
||||
assertThat(hits).isNotEmpty()
|
||||
assertThat(hits.map { it.id }).contains("Europe/Berlin")
|
||||
// Every hit genuinely carries that abbreviation — nothing bled in.
|
||||
assertThat(hits.all { it.shortName.equals("CEST", ignoreCase = true) }).isTrue()
|
||||
// Case doesn't matter.
|
||||
assertThat(filter("CEST").map { it.id }).isEqualTo(hits.map { it.id })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a city starting with the query outranks one merely containing it`() {
|
||||
val ids = filter("york").map { it.id }
|
||||
|
||||
Reference in New Issue
Block a user