Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluation happens twice with dapui.eval #265

Closed
Ultimator14 opened this issue Apr 22, 2023 · 1 comment
Closed

Evaluation happens twice with dapui.eval #265

Ultimator14 opened this issue Apr 22, 2023 · 1 comment

Comments

@Ultimator14
Copy link

I'm debugging a python program with debugpy.
When evaluation an expression (using dapui.eval) that changes a value, the evaluation is done twice.
This does not happen with the dap repl window.

Steps to reproduce:

  1. Use this test program
a = [1]
print(len(a))
print(len(a)) <-- insert breakpoint here
print(len(a))
  1. Insert breakpoint at line 3
  2. Run program, first print shows [1]
  3. Execute :lua require('dapui').eval("a.append(2)") on breakpoint
  4. Step next
  5. a is now [1,2,2] instead of [1,2]

Note: Initially, I tried the built in expression (watches) element. But since all the expressions there are recomputed on refresh, the change would be executed all the time, too (which is probably not fixable). Instead, I created a separate keybinding for executing expressions without displaying them in the expressions window.

local function dapui_prompt_eval()
	local expr = vim.fn.input('Expression: ')
	if vim.fn.empty(expr) ~= 0 then return end
	eval(expr, {})
end

vim.keymap.set('n', '<leader>sE', dapui_prompt_eval, { desc = "Evaluate expression", silent = true })
rcarriga added a commit that referenced this issue May 27, 2023
Buffers can be assumed to have already rendered when opening in a
window.

See #265
@rcarriga
Copy link
Owner

Thanks for the report, this should now be working as expected 😄 As you said this is not fixable for watches. Really the hover shouldn't have any side effects but of course that's easier said than done for a debugger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants