Skip to content

Commit

Permalink
Merge pull request #14 from tompng/fix/crash-when-noautocomplete
Browse files Browse the repository at this point in the history
Fix crash in tab-completion with --noautocomplete
  • Loading branch information
tompng authored May 30, 2023
2 parents 79b91d2 + cb9401c commit 253186d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/katakata_irb/completor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions test/test_katakata_irb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(&)
Expand Down

0 comments on commit 253186d

Please sign in to comment.