From 94625d51d6d4c66679838e56b4daa09ee31a1613 Mon Sep 17 00:00:00 2001 From: hyuraku <32809703+hyuraku@users.noreply.github.com> Date: Thu, 24 Mar 2022 23:02:55 +0900 Subject: [PATCH 1/3] repair search_casks --- Library/Homebrew/extend/os/mac/search.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/extend/os/mac/search.rb b/Library/Homebrew/extend/os/mac/search.rb index 4fee7f8f37..76763251f4 100644 --- a/Library/Homebrew/extend/os/mac/search.rb +++ b/Library/Homebrew/extend/os/mac/search.rb @@ -36,8 +36,10 @@ module Homebrew results = cask_tokens.extend(Searchable) .search(string_or_regex) - results |= DidYouMean::SpellChecker.new(dictionary: cask_tokens) - .correct(string_or_regex) + if results.empty? + cask_names = Cask::Cask.all.map(&:full_name) + results = DidYouMean::SpellChecker.new(dictionary: cask_names).correct(string_or_regex) + end results.sort.map do |name| cask = Cask::CaskLoader.load(name) From 0758631d3db05338f79aa675a963891eafcf50db Mon Sep 17 00:00:00 2001 From: hyuraku <32809703+hyuraku@users.noreply.github.com> Date: Mon, 28 Mar 2022 21:41:40 +0900 Subject: [PATCH 2/3] remove if condition --- Library/Homebrew/extend/os/mac/search.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/extend/os/mac/search.rb b/Library/Homebrew/extend/os/mac/search.rb index 76763251f4..5ead324149 100644 --- a/Library/Homebrew/extend/os/mac/search.rb +++ b/Library/Homebrew/extend/os/mac/search.rb @@ -36,10 +36,9 @@ module Homebrew results = cask_tokens.extend(Searchable) .search(string_or_regex) - if results.empty? - cask_names = Cask::Cask.all.map(&:full_name) - results = DidYouMean::SpellChecker.new(dictionary: cask_names).correct(string_or_regex) - end + cask_names = Cask::Cask.all.map(&:full_name) + results |= DidYouMean::SpellChecker.new(dictionary: cask_names) + .correct(string_or_regex) results.sort.map do |name| cask = Cask::CaskLoader.load(name) @@ -48,7 +47,7 @@ module Homebrew else cask.token end - end + end.uniq end end From e486c8710ba32a428d1349b5bc46fdef96254aea Mon Sep 17 00:00:00 2001 From: hyuraku <32809703+hyuraku@users.noreply.github.com> Date: Mon, 28 Mar 2022 23:57:21 +0900 Subject: [PATCH 3/3] change the operator --- Library/Homebrew/extend/os/mac/search.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/os/mac/search.rb b/Library/Homebrew/extend/os/mac/search.rb index 5ead324149..1f27d89cfe 100644 --- a/Library/Homebrew/extend/os/mac/search.rb +++ b/Library/Homebrew/extend/os/mac/search.rb @@ -37,7 +37,7 @@ module Homebrew .search(string_or_regex) cask_names = Cask::Cask.all.map(&:full_name) - results |= DidYouMean::SpellChecker.new(dictionary: cask_names) + results += DidYouMean::SpellChecker.new(dictionary: cask_names) .correct(string_or_regex) results.sort.map do |name|