Skip to content

Commit e48c811

Browse files
committed
Try to fetch frames in frames widget if they're missing
1 parent 0406598 commit e48c811

File tree

2 files changed

+32
-21
lines changed

2 files changed

+32
-21
lines changed

lua/dap/protocol.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
---@field presentationHint nil|"normal"|"label"|"subtle";
6262
---@field scopes? dap.Scope[] Not part of spec; added by nvim-dap
6363

64+
---@class dap.StackTraceResponse
65+
---@field stackFrames dap.StackFrame[]
66+
---@field totalFrames? number
6467

6568
---@class dap.Scope
6669
---@field name string

lua/dap/ui/widgets.lua

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -236,30 +236,38 @@ M.frames = {
236236
layer.render({msg})
237237
return
238238
end
239+
239240
local frames = thread.frames
240-
if not frames then
241-
layer.render({"Stopped thread has no frames"})
242-
return
243-
end
244-
local context = {}
245-
context.actions = {
246-
{
247-
label = "Jump to frame",
248-
fn = function(_, frame)
249-
if session then
250-
local close = vim.bo.bufhidden == "wipe"
251-
session:_frame_set(frame)
252-
if close then
253-
view.close()
241+
require("dap.async").run(function()
242+
if not frames then
243+
local err, response = session:request("stackTrace", { threadId = thread.id })
244+
---@cast response dap.StackTraceResponse
245+
if err or not response then
246+
layer.render({"Stopped thread has no frames"})
247+
return
248+
end
249+
frames = response.stackFrames
250+
end
251+
local context = {}
252+
context.actions = {
253+
{
254+
label = "Jump to frame",
255+
fn = function(_, frame)
256+
if session then
257+
local close = vim.bo.bufhidden == "wipe"
258+
session:_frame_set(frame)
259+
if close then
260+
view.close()
261+
end
262+
else
263+
utils.notify('Cannot navigate to frame without active session', vim.log.levels.INFO)
254264
end
255-
else
256-
utils.notify('Cannot navigate to frame without active session', vim.log.levels.INFO)
257265
end
258-
end
259-
},
260-
}
261-
local render_frame = require('dap.entity').frames.render_item
262-
layer.render(frames, render_frame, context)
266+
},
267+
}
268+
local render_frame = require('dap.entity').frames.render_item
269+
layer.render(frames, render_frame, context)
270+
end)
263271
end
264272
}
265273

0 commit comments

Comments
 (0)