@@ -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