Skip to content

Commit

Permalink
Set view context on expression widgets
Browse files Browse the repository at this point in the history
Makes sure the close behavior of setVariable/setExpression works
  • Loading branch information
mfussenegger committed Jun 2, 2024
1 parent ad363a3 commit 9bb1333
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lua/dap/ui/widgets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,12 @@ do
local frame = session.current_frame or {}
local scopes = frame.scopes or {}
session:evaluate(args, function(err, resp)
local spec = vim.deepcopy(require('dap.entity').variable.tree_spec)
spec.extra_context = { view = view }
if err then
local variable = find_var(scopes, expression)
if variable then
local tree = ui.new_tree(require('dap.entity').variable.tree_spec)
local tree = ui.new_tree(spec)
tree.render(view.layer(), variable)
else
local msg = 'Cannot evaluate "'..expression..'"!'
Expand All @@ -404,7 +406,7 @@ do
elseif resp and resp.result then
local attributes = (resp.presentationHint or {}).attributes or {}
if resp.variablesReference > 0 or vim.tbl_contains(attributes, "rawString") then
local tree = ui.new_tree(require('dap.entity').variable.tree_spec)
local tree = ui.new_tree(spec)
tree.render(layer, resp)
else
local lines = vim.split(resp.result, "\n", { plain = true })
Expand Down

0 comments on commit 9bb1333

Please sign in to comment.