diff --git a/lib/debug/completor.rb b/lib/debug/completor.rb new file mode 100644 index 000000000..b6a485a0e --- /dev/null +++ b/lib/debug/completor.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require "irb/completion" + +module DEBUGGER__ + class Completor + class << self + # old IRB completion API + if defined?(IRB::InputCompletor) + def retrieve_completion_data(input, binding) + IRB::InputCompletor.retrieve_completion_data(input, bind: binding).compact + end + else + COMPLETOR = IRB::RegexpCompletor.new + + def retrieve_completion_data(input, binding) + COMPLETOR.retrieve_completion_data(input, bind: binding, doc_namespace: false).compact + end + end + end + end +end diff --git a/lib/debug/server_dap.rb b/lib/debug/server_dap.rb index 8dbefda8a..6328a462e 100644 --- a/lib/debug/server_dap.rb +++ b/lib/debug/server_dap.rb @@ -5,6 +5,8 @@ require 'tmpdir' require 'fileutils' +require_relative 'completor' + module DEBUGGER__ module UI_DAP SHOW_PROTOCOL = ENV['DEBUG_DAP_SHOW_PROTOCOL'] == '1' || ENV['RUBY_DEBUG_DAP_SHOW_PROTOCOL'] == '1' @@ -980,7 +982,7 @@ def process_dap args frame = get_frame(fid) if (b = frame&.binding) && word = text&.split(/[\s\{]/)&.last - words = IRB::InputCompletor::retrieve_completion_data(word, bind: b).compact + words = Completor.retrieve_completion_data(word, b) end event! :protocol_result, :completions, req, targets: (words || []).map{|phrase|