mirror of
https://github.com/mfussenegger/nvim-dap
synced 2024-09-16 14:24:03 +02:00
Provide feedback if item in variable tree has no children to expand
This commit is contained in:
parent
316f4edd1e
commit
7b18c319b0
3 changed files with 12 additions and 7 deletions
|
@ -56,6 +56,8 @@ function variable.has_children(var)
|
|||
return (var.variables and #var.variables > 0) or var.variablesReference ~= 0
|
||||
end
|
||||
|
||||
---@param var dap.Variable
|
||||
---@result dap.Variable[]
|
||||
function variable.get_children(var)
|
||||
if islist(var.variables) then
|
||||
return var.variables
|
||||
|
@ -78,11 +80,12 @@ local function cmp_vars(a, b)
|
|||
end
|
||||
|
||||
|
||||
---@param var dap.Variable
|
||||
function variable.fetch_children(var, cb)
|
||||
local session = require('dap').session()
|
||||
if var.variables then
|
||||
cb(variable.get_children(var))
|
||||
elseif session and var.variablesReference then
|
||||
elseif session and var.variablesReference > 0 then
|
||||
|
||||
---@param err? dap.ErrorResponse
|
||||
---@param resp? dap.VariableResponse
|
||||
|
@ -93,11 +96,11 @@ function variable.fetch_children(var, cb)
|
|||
local variables = resp.variables
|
||||
local unloaded = #variables
|
||||
local function countdown()
|
||||
unloaded = unloaded - 1
|
||||
if unloaded == 0 then
|
||||
var.variables = variables
|
||||
cb(variables)
|
||||
end
|
||||
unloaded = unloaded - 1
|
||||
if unloaded == 0 then
|
||||
var.variables = variables
|
||||
cb(variables)
|
||||
end
|
||||
end
|
||||
|
||||
table.sort(variables, cmp_vars)
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
---@field type? string
|
||||
---@field presentationHint? dap.VariablePresentationHint
|
||||
---@field evaluateName? string
|
||||
---@field variablesReference number
|
||||
---@field variablesReference number if > 0 the variable is structured
|
||||
---@field namedVariables? number
|
||||
---@field indexedVariables? number
|
||||
---@field memoryReference? string
|
||||
|
|
|
@ -257,6 +257,8 @@ function M.new_tree(opts)
|
|||
collapse(layer, value, lnum, context)
|
||||
elseif opts.has_children(value) then
|
||||
expand(layer, value, lnum, context)
|
||||
else
|
||||
utils.notify("No children on line " .. tostring(lnum) .. ". Can't expand", vim.log.levels.INFO)
|
||||
end
|
||||
end,
|
||||
|
||||
|
|
Loading…
Reference in a new issue