From f7d997683f9a31c868581bd7c486332bb238cfbf Mon Sep 17 00:00:00 2001 From: Simon Roberts Date: Tue, 12 Oct 2021 08:44:17 +1100 Subject: [PATCH] Minimize diff --- cointop/search.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cointop/search.go b/cointop/search.go index 3343811..fd455ff 100644 --- a/cointop/search.go +++ b/cointop/search.go @@ -107,12 +107,16 @@ func (ct *Cointop) Search(q string) error { coin := ct.State.allCoins[i] name := strings.ToLower(coin.Name) symbol := strings.ToLower(coin.Symbol) - // if query matches name or symbol, return immediately - if name == q || symbol == q { + // if query matches symbol, return immediately + if symbol == q { + ct.GoToGlobalIndex(i) + return nil + } + // if query matches name, return immediately + if name == q { ct.GoToGlobalIndex(i) return nil } - // store index with the smallest levenshtein dist := levenshtein.DamerauLevenshteinDistance(name, q) if min == -1 || dist <= min {