Skip to content
Open
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
5 changes: 4 additions & 1 deletion lib/debug/server_dap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,10 @@ 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
# InputCompletor is deprecated and forwards here (debug#1079).
words = IRB::RegexpCompletor.new.retrieve_completion_data(
word, bind: b, doc_namespace: false
).compact
end

event! :protocol_result, :completions, req, targets: (words || []).map{|phrase|
Expand Down
30 changes: 30 additions & 0 deletions test/protocol/completion_deprecation_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

require_relative '../support/protocol_test_case'

module DEBUGGER__
class CompletionDeprecationTest < ProtocolTestCase
PROGRAM = <<~RUBY
1| a = 1
2| a.itself
RUBY

def test_completions_do_not_warn_about_input_completor
previous = ENV['RUBYOPT']
# deprecate_constant is silent unless verbose warnings are on
ENV['RUBYOPT'] = [previous, '-w'].compact.join(' ')
run_protocol_scenario PROGRAM, cdp: false do
find_response :event, 'stopped', 'V<D'
frames = send_dap_request 'stackTrace', threadId: 1, startFrame: 0, levels: 20
frame_id = frames.dig(:body, :stackFrames, 0, :id)
res = send_custom_dap_request 'completions', frameId: frame_id, text: 'Ar', column: 2, line: 1
labels = res.dig(:body, :targets).map {|target| target[:label] }
assert_include labels, 'Array'
assert_not_match(/InputCompletor/, @remote_info.debuggee_backlog.join)
req_terminate_debuggee
end
ensure
ENV['RUBYOPT'] = previous
end
end
end