[前][次][番号順一覧][スレッド一覧]

ruby-changes:73918

From: st0012 <ko1@a...>
Date: Sat, 8 Oct 2022 03:18:01 +0900 (JST)
Subject: [ruby-changes:73918] 5b3079a8a5 (master): [ruby/irb] Sort constant completion's candidates

https://git.ruby-lang.org/ruby.git/commit/?id=5b3079a8a5

From 5b3079a8a5f66859c8d80ad55b5424c7c1877443 Mon Sep 17 00:00:00 2001
From: st0012 <stan001212@g...>
Date: Thu, 6 Oct 2022 12:37:37 +0100
Subject: [ruby/irb] Sort constant completion's candidates

https://github.com/ruby/irb/commit/ee9b33c817
---
 lib/irb/completion.rb       | 2 +-
 test/irb/test_completion.rb | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb
index 9d386bbeca..dbd652769e 100644
--- a/lib/irb/completion.rb
+++ b/lib/irb/completion.rb
@@ -255,7 +255,7 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/completion.rb#L255
             candidates = []
           end
 
-          select_message(receiver, message, candidates, "::")
+          select_message(receiver, message, candidates.sort, "::")
         end
 
       when /^(:[^:.]+)(\.|::)([^.]*)$/
diff --git a/test/irb/test_completion.rb b/test/irb/test_completion.rb
index 4ca7f298ff..df5a78c69d 100644
--- a/test/irb/test_completion.rb
+++ b/test/irb/test_completion.rb
@@ -196,13 +196,14 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_completion.rb#L196
 
     class TestConstantCompletion < TestCompletion
       class Foo
+        B3 = 1
         B1 = 1
-        B2 = 2
+        B2 = 1
       end
 
       def test_complete_constants
         assert_equal(["Foo"], IRB::InputCompletor.retrieve_completion_data("Fo", bind: binding))
-        assert_equal(["Foo::B1", "Foo::B2"], IRB::InputCompletor.retrieve_completion_data("Foo::B", bind: binding))
+        assert_equal(["Foo::B1", "Foo::B2", "Foo::B3"], IRB::InputCompletor.retrieve_completion_data("Foo::B", bind: binding))
         assert_equal(["Foo::B1.positive?"], IRB::InputCompletor.retrieve_completion_data("Foo::B1.pos", bind: binding))
 
         assert_equal(["::Forwardable"], IRB::InputCompletor.retrieve_completion_data("::Fo", bind: binding))
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]