Merge pull request #12376 from FnControlOption/search-casks

search: optimize cask search
This commit is contained in:
Mike McQuaid 2021-11-04 09:16:19 +00:00 committed by GitHub
commit ed5ae17051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,9 +31,16 @@ module Homebrew
end end
end end
results = Cask::Cask.search(string_or_regex, &:token).sort_by(&:token) cask_tokens = Tap.flat_map(&:cask_tokens)
results.map do |cask| results = cask_tokens.extend(Searchable)
.search(string_or_regex)
results |= DidYouMean::SpellChecker.new(dictionary: cask_tokens)
.correct(string_or_regex)
results.sort.map do |name|
cask = Cask::CaskLoader.load(name)
if cask.installed? if cask.installed?
pretty_installed(cask.token) pretty_installed(cask.token)
else else