Skip to content

Commit 04cd5e7

Browse files
小野 直人ko1
authored andcommitted
Make sure to get break numbers correctly
Fixes #361
1 parent accc536 commit 04cd5e7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/debug/server_cdp.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def send_event method, **params
9595
end
9696

9797
def process
98-
bps = []
98+
bps = {}
9999
@src_map = {}
100100
loop do
101101
req = @web_sock.extract_data
@@ -187,20 +187,25 @@ def process
187187
src = get_source_code path
188188
end_line = src.count("\n")
189189
line = end_line if line > end_line
190+
b_id = "#{bps.size+1}:#{line}:#{path}"
190191
if cond != ''
191-
bps << SESSION.add_line_breakpoint(path, line + 1, cond: cond)
192+
SESSION.add_line_breakpoint(path, line + 1, cond: cond)
193+
bps[b_id] = bps.size
192194
else
193-
bps << SESSION.add_line_breakpoint(path, line + 1)
195+
SESSION.add_line_breakpoint(path, line + 1)
196+
bps[b_id] = bps.size
194197
end
195198
send_response req,
196-
breakpointId: (bps.size - 1).to_s,
199+
breakpointId: b_id,
197200
locations: [
198201
scriptId: path,
199202
lineNumber: line
200203
]
201204
when 'Debugger.removeBreakpoint'
202205
b_id = req.dig('params', 'breakpointId')
203-
@q_msg << "del #{b_id}"
206+
idx = bps[b_id]
207+
bps.each_value{|i| i -= 1 if i > idx}
208+
@q_msg << "del #{idx}"
204209
send_response req
205210

206211
when 'Debugger.evaluateOnCallFrame', 'Runtime.getProperties'

0 commit comments

Comments
 (0)