1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Make suggestions order stable [Bug #16263]

As the result order of `DidYouMean::SpellChecker#correct` is
undefined, keep the order of the original candidates.
This commit is contained in:
Nobuyoshi Nakada 2019-10-21 09:12:38 +09:00
parent 71ffe40a44
commit 263ee6639d
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -1787,7 +1787,7 @@ XXX
end
all_candidates.select! {|cand| cand.is_a?(String) }
checker = DidYouMean::SpellChecker.new(dictionary: all_candidates)
DidYouMean.formatter.message_for(checker.correct(opt))
DidYouMean.formatter.message_for(all_candidates & checker.correct(opt))
end
def candidate(word)