Skip to content

Commit e99c656

Browse files
committed
为非vscode前端提供降级方案
1 parent 883f763 commit e99c656

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

extension/script/backend/worker.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ function CMD.setBreakpoints(pkg)
456456
if noDebug or not source.valid(pkg.source) then
457457
return
458458
end
459-
breakpoint.set_bp(pkg.source, pkg.breakpoints, pkg.content)
459+
breakpoint.set_bp(pkg.source, pkg.breakpoints, pkg.content or false)
460460
end
461461

462462
function CMD.setFunctionBreakpoints(pkg)

extension/script/backend/worker/breakpoint.lua

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,23 @@ local function verifyBreakpointByLineInfo(src, breakpoints)
178178
end
179179
end
180180

181+
-- 降级模式:无 lineinfo 时跳过行号校正,直接标记断点为 verified
182+
local function verifyBreakpointWithoutLineInfo(src, breakpoints)
183+
for _, bp in ipairs(breakpoints) do
184+
if bp.unverified ~= nil then
185+
goto continue
186+
end
187+
bp.source = src
188+
bp.verified = true
189+
ev.emit('breakpoint', 'changed', {
190+
id = bp.id,
191+
line = bp.line,
192+
verified = true,
193+
})
194+
::continue::
195+
end
196+
end
197+
181198
function m.find(src, currentline)
182199
local currentBP = currentactive[bpKey(src)]
183200
if not currentBP then
@@ -239,6 +256,7 @@ function m.set_bp(clientsrc, breakpoints, content)
239256
if srcarray then
240257
local ok = false
241258
for _, src in ipairs(srcarray) do
259+
src.content = content
242260
if calcLineInfo(src, content) then
243261
ok = true
244262
end
@@ -248,6 +266,12 @@ function m.set_bp(clientsrc, breakpoints, content)
248266
verifyBreakpointByLineInfo(src, breakpoints)
249267
updateBreakpoint(src, breakpoints)
250268
end
269+
elseif content == false then
270+
-- 降级路径:前端已上报但 sourceContent 为空
271+
for _, src in ipairs(srcarray) do
272+
verifyBreakpointWithoutLineInfo(src, breakpoints)
273+
updateBreakpoint(src, breakpoints)
274+
end
251275
else
252276
cantVerifyBreakpoints(breakpoints)
253277
end
@@ -298,10 +322,17 @@ function m.newproto(proto, src, key)
298322
local bpkey = bpClientKey(src)
299323
local wv = waitverify[bpkey]
300324
if wv then
325+
src.content = wv.content
301326
if not src.content then
302327
waitverify[bpkey] = nil
303328
end
304329
if not calcLineInfo(src, wv.content) then
330+
if src.content == false then
331+
-- 降级路径:前端已上报但 sourceContent 为空
332+
verifyBreakpointWithoutLineInfo(src, wv.breakpoints)
333+
updateBreakpoint(src, wv.breakpoints)
334+
return
335+
end
305336
cantVerifyBreakpoints(wv.breakpoints)
306337
return
307338
end

0 commit comments

Comments
 (0)