Skip to content

Commit 74a3386

Browse files
committed
Extract get_frame method
1 parent c6e3a82 commit 74a3386

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

lib/debug/server_cdp.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ def process_cdp args
710710
when :evaluate
711711
res = {}
712712
fid, expr = args
713-
frame = @target_frames[fid]
713+
frame = get_frame(fid)
714714
message = nil
715715

716716
if frame && (b = frame.binding)
@@ -779,7 +779,7 @@ def process_cdp args
779779
event! :cdp_result, :evaluate, req, message: message, response: res, output: output
780780
when :scope
781781
fid = args.shift
782-
frame = @target_frames[fid]
782+
frame = get_frame(fid)
783783
if b = frame.binding
784784
vars = b.local_variables.map{|name|
785785
v = b.local_variable_get(name)

lib/debug/server_dap.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ def process_dap args
612612
}
613613
when :scopes
614614
fid = args.shift
615-
frame = @target_frames[fid]
615+
frame = get_frame(fid)
616616

617617
lnum =
618618
if frame.binding
@@ -640,7 +640,7 @@ def process_dap args
640640
}]
641641
when :scope
642642
fid = args.shift
643-
frame = @target_frames[fid]
643+
frame = get_frame(fid)
644644
if b = frame.binding
645645
vars = b.local_variables.map{|name|
646646
v = b.local_variable_get(name)
@@ -712,7 +712,7 @@ def process_dap args
712712

713713
when :evaluate
714714
fid, expr, context = args
715-
frame = @target_frames[fid]
715+
frame = get_frame(fid)
716716
message = nil
717717

718718
if frame && (b = frame.binding)
@@ -774,7 +774,7 @@ def process_dap args
774774

775775
when :completions
776776
fid, text = args
777-
frame = @target_frames[fid]
777+
frame = get_frame(fid)
778778

779779
if (b = frame&.binding) && word = text&.split(/[\s\{]/)&.last
780780
words = IRB::InputCompletor::retrieve_completion_data(word, bind: b).compact

lib/debug/thread_client.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,12 @@ def show_src(frame_index: @current_frame_index,
432432
end
433433

434434
def current_frame
435+
get_frame(@current_frame_index)
436+
end
437+
438+
def get_frame(index)
435439
if @target_frames
436-
@target_frames[@current_frame_index]
440+
@target_frames[index]
437441
else
438442
nil
439443
end

0 commit comments

Comments
 (0)