Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DAP's completion request with new IRB's completor #1025

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/debug/completor.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion lib/debug/server_dap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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|
Expand Down