mirror of
https://github.com/mfussenegger/nvim-dap
synced 2024-09-16 14:24:03 +02:00
Use scopes from response without copy
This commit is contained in:
parent
5823403923
commit
0a5c5093e4
3 changed files with 29 additions and 16 deletions
|
@ -175,7 +175,7 @@ function M._load_json(jsonstr)
|
|||
end
|
||||
|
||||
---@param path string?
|
||||
---@return Configuration[]
|
||||
---@return dap.Configuration[]
|
||||
function M.getconfigs(path)
|
||||
local resolved_path = path or (vim.fn.getcwd() .. '/.vscode/launch.json')
|
||||
if not vim.loop.fs_stat(resolved_path) then
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
---@field stackFrames dap.StackFrame[]
|
||||
---@field totalFrames? number
|
||||
|
||||
|
||||
---@class dap.Scope
|
||||
---@field name string
|
||||
---@field presentationHint? "arguments"|"locals"|"registers"|string
|
||||
|
@ -79,6 +80,11 @@
|
|||
---@field endColumn? number
|
||||
---@field variables? table<string, dap.Variable> by variable name. Not part of spec
|
||||
|
||||
|
||||
---@class dap.ScopesResponse
|
||||
---@field scopes dap.Scope[]
|
||||
|
||||
|
||||
---@class dap.ValueFormat
|
||||
---@field hex? boolean Display the value in hex
|
||||
|
||||
|
|
|
@ -760,27 +760,34 @@ end
|
|||
|
||||
---@param current_frame dap.StackFrame
|
||||
function Session:_request_scopes(current_frame)
|
||||
self:request('scopes', { frameId = current_frame.id }, function(_, scopes_resp)
|
||||
if not scopes_resp or not scopes_resp.scopes then
|
||||
local params = {
|
||||
frameId = current_frame.id
|
||||
}
|
||||
---@param scope_resp dap.ScopesResponse?
|
||||
local function on_scopes(_, scope_resp)
|
||||
if not scope_resp then
|
||||
return
|
||||
end
|
||||
current_frame.scopes = {}
|
||||
for _, scope in pairs(scopes_resp.scopes) do
|
||||
table.insert(current_frame.scopes, scope)
|
||||
local scopes = scope_resp.scopes
|
||||
current_frame.scopes = scopes
|
||||
local function toname(var)
|
||||
return var.name
|
||||
end
|
||||
for _, scope in ipairs(scopes) do
|
||||
if not scope.expensive then
|
||||
local params = { variablesReference = scope.variablesReference }
|
||||
self:request('variables', params, function(_, variables_resp)
|
||||
if not variables_resp then
|
||||
return
|
||||
|
||||
---@param resp dap.VariableResponse?
|
||||
local function on_variables(_, resp)
|
||||
if resp then
|
||||
scope.variables = utils.to_dict(resp.variables, toname)
|
||||
end
|
||||
scope.variables = utils.to_dict(
|
||||
variables_resp.variables,
|
||||
function(v) return v.name end
|
||||
)
|
||||
end)
|
||||
end
|
||||
local varparams = { variablesReference = scope.variablesReference }
|
||||
self:request('variables', varparams, on_variables)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
self:request('scopes', params, on_scopes)
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue