diff --git a/integration/history.go b/integration/history.go index d3d37c2..cfe6dd0 100644 --- a/integration/history.go +++ b/integration/history.go @@ -140,10 +140,24 @@ func SearchHistory(query string) ([]HistResult, error) { return results, nil } - matches := searcherCache.SearchWithScores(query, &fuzzy.SearchOptions{Limit: 100}) + matches := searcherCache.SearchWithScores(query, &fuzzy.SearchOptions{Limit: 200}) + + // when query has a clear first word, only keep history entries that share the same first word + // this prevents e.g. curl commands from showing up when typing "git ..." + queryFirstWord := "" + if fields := strings.Fields(query); len(fields) > 0 { + queryFirstWord = strings.ToLower(fields[0]) + } var results []HistResult for _, m := range matches { + if queryFirstWord != "" { + if fields := strings.Fields(m.Str); len(fields) > 0 { + if strings.ToLower(fields[0]) != queryFirstWord { + continue + } + } + } results = append(results, HistResult{ ID: idMapCache[m.Str], Cmd: m.Str,