Skip to content

Commit 1fe98bc

Browse files
committed
perf(watches): remove unnecessary listener
1 parent 87cfa3d commit 1fe98bc

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

lua/dap-view/listeners.lua

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,6 @@ dap.listeners.after.stackTrace[SUBSCRIPTION_ID] = function(_, err, _, payload)
153153
end
154154
end
155155

156-
dap.listeners.after.variables[SUBSCRIPTION_ID] = function()
157-
-- When setting a variable for some adapters, the request may be slow.
158-
-- And by the time we refresh the view "regularly", the data might not be up-to-date.
159-
-- To avoid dealing with such edge cases, we force redrawing after the variables request.
160-
-- This introduces an overrhead, but its robustness should be worth it
161-
if state.current_section == "watches" then
162-
require("dap-view.views").switch_to_view("watches")
163-
end
164-
end
165-
166156
local reeval = { "setExpression", "setVariable" }
167157

168158
for _, listener in ipairs(reeval) do

lua/dap-view/watches/actions.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ M.expand_or_collapse = function(line, co)
167167
if variable_view then
168168
variable_view.expanded = not variable_view.expanded
169169

170-
variable_view.children, variable_view.err = eval.expand_variable(reference)
170+
variable_view.children, variable_view.err = eval.expand_variable(reference, nil, co)
171+
172+
return true
171173
end
172174
else
173175
vim.notify("Nothing to expand")

lua/dap-view/watches/eval.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ end
9191

9292
---@param variables_reference number
9393
---@param previous_expansion_result dapview.VariableView[]?
94-
M.expand_variable = function(variables_reference, previous_expansion_result)
94+
---@param co thread?
95+
M.expand_variable = function(variables_reference, previous_expansion_result, co)
9596
local session = assert(require("dap").session(), "has active session")
9697

9798
local frame_id = session.current_frame and session.current_frame.id
@@ -159,6 +160,10 @@ M.expand_variable = function(variables_reference, previous_expansion_result)
159160
varible_views[k] = new_variable_view
160161
end
161162

163+
if co then
164+
coroutine.resume(co)
165+
end
166+
162167
return #varible_views > 0 and varible_views or nil, err
163168
end
164169

0 commit comments

Comments
 (0)