From 263ee6639d6f9f599613a20731c0646d125e0813 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 21 Oct 2019 09:12:38 +0900 Subject: [PATCH] Make suggestions order stable [Bug #16263] As the result order of `DidYouMean::SpellChecker#correct` is undefined, keep the order of the original candidates. --- lib/optparse.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/optparse.rb b/lib/optparse.rb index b0284850cf..9745e4d662 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -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)