diff --git a/lib/katakata_irb/completor.rb b/lib/katakata_irb/completor.rb index e01a96d..c87d918 100644 --- a/lib/katakata_irb/completor.rb +++ b/lib/katakata_irb/completor.rb @@ -61,7 +61,7 @@ def self.setup end IRB::InputCompletor.singleton_class.prepend Module.new{ - def retrieve_completion_data(input, _bind: IRB.conf[:MAIN_CONTEXT].workspace.binding, doc_namespace: false) + def retrieve_completion_data(input, doc_namespace: false, **) return super unless doc_namespace name = input[/[a-zA-Z_0-9]+[!?=]?\z/] method_doc = -> type do diff --git a/test/test_katakata_irb.rb b/test/test_katakata_irb.rb index 666a7c1..70214dc 100644 --- a/test/test_katakata_irb.rb +++ b/test/test_katakata_irb.rb @@ -39,6 +39,15 @@ def output.puts(*) end end + def test_irb_input_completor_compatibility + completion = IRB::InputCompletor.retrieve_completion_data 'at_exi', bind: binding, doc_namespace: false + assert_equal ['at_exit'], completion + + KatakataIrb::Completor.prev_analyze_result = KatakataIrb::Completor.analyze 'a = 1.to_c; a.abs', binding + document = IRB::InputCompletor.retrieve_completion_data 'a.abs', bind: binding, doc_namespace: true + assert_equal 'Complex#abs', document + end + SYNTAX_TEST_CODE_3_1_PLUS = <<~'RUBY' def f(*,**,&) f(&)