Skip to content

Commit 4f73b98

Browse files
committed
fix(scopes): handle missing variables from all scopes
1 parent 2896bc2 commit 4f73b98

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lua/dap-view/scopes/view.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ M.show = function()
138138
end
139139
end
140140

141+
local has_variables = false
142+
141143
local line = 0
142144

143145
---@type dapview.Canvas
@@ -150,7 +152,29 @@ M.show = function()
150152

151153
line = line + 1
152154

155+
local prev_line = line
156+
153157
line = show_variables(scope.variablesReference, scope.name, line, 1, canvas)
158+
159+
if prev_line ~= line then
160+
has_variables = true
161+
end
162+
end
163+
164+
-- Sometimes the JS debug adapter simply does not return any variables at all, in spite of
165+
-- returning the scopes themselves. This happens, for instance, when debugging firebase functions.
166+
-- Upon refreshing the scopes for a function that is no longer in execution.
167+
--
168+
-- This could be a bug in nvim-dap where it does not refresh the scopes, or a bug with the
169+
-- adapter itself, where it doesn't send the updated scopes (if there are none)
170+
--
171+
-- Either way, that's not much of a big deal
172+
--
173+
-- More concerning though, is the fact that if the user does not force a refresh,
174+
-- The scopes may show "outdated info" until a trigger to refresh is hit
175+
-- But I guess that's more of a feature instead of a bug?
176+
if views.cleanup_view(not has_variables, "No variables returned from adapter") then
177+
return
154178
end
155179

156180
util.set_lines(state.bufnr, 0, line - 1, false, canvas.contents)

0 commit comments

Comments
 (0)