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

ruby-changes:67593

From: aycabta <ko1@a...>
Date: Sat, 4 Sep 2021 17:48:35 +0900 (JST)
Subject: [ruby-changes:67593] 6fa37d2666 (master): [ruby/irb] Retrieve completed receiver that is a module or class correctly

https://git.ruby-lang.org/ruby.git/commit/?id=6fa37d2666

From 6fa37d26666b1c7e009d661beb8c13fe39ce1b7f Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Sat, 4 Sep 2021 05:33:03 +0900
Subject: [ruby/irb] Retrieve completed receiver that is a module or class
 correctly

https://github.com/ruby/irb/commit/b2324727e1
---
 lib/irb/completion.rb       | 3 ++-
 test/irb/test_completion.rb | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb
index c7c0fb9..385957c 100644
--- a/lib/irb/completion.rb
+++ b/lib/irb/completion.rb
@@ -296,7 +296,8 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/completion.rb#L296
           candidates.uniq!
         end
         if doc_namespace
-          "#{rec.class.name}#{sep}#{candidates.find{ |i| i == message }}"
+          rec_class = rec.is_a?(Module) ? rec : rec.class
+          "#{rec_class.name}#{sep}#{candidates.find{ |i| i == message }}"
         else
           select_message(receiver, message, candidates, sep)
         end
diff --git a/test/irb/test_completion.rb b/test/irb/test_completion.rb
index 260b8a8..a661d68 100644
--- a/test/irb/test_completion.rb
+++ b/test/irb/test_completion.rb
@@ -89,5 +89,10 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_completion.rb#L89
       assert_include(IRB::InputCompletor.retrieve_completion_data("str_examp", bind: binding), "str_example")
       assert_equal(IRB::InputCompletor.retrieve_completion_data("str_example", bind: binding, doc_namespace: true), "String")
     end
+
+    def test_complete_class_method
+      assert_include(IRB::InputCompletor.retrieve_completion_data("String.new", bind: binding), "String.new")
+      assert_equal(IRB::InputCompletor.retrieve_completion_data("String.new", bind: binding, doc_namespace: true), "String.new")
+    end
   end
 end
-- 
cgit v1.1


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

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