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

Suggestion: Only execute dapui.eval(), if an active session exists #163

Closed
elagil opened this issue Nov 2, 2022 · 2 comments
Closed

Suggestion: Only execute dapui.eval(), if an active session exists #163

elagil opened this issue Nov 2, 2022 · 2 comments

Comments

@elagil
Copy link

elagil commented Nov 2, 2022

Currently, executing dapui.eval() without an active session yields an empty box. That might not be the intended behavior.
I use a wrapper around dapui.eval(), which might be a useful default:

--- Only execute the provided function in an active DAP session.
local execute_if_dap_active = function(fn)
    if require("dap").session() == nil then
        --- dap.session() returns the active session, or `nil`, if there is no active session.
        return
    else
        fn()
    end
end

--- Then, I use this mapping.
vim.keymap.set("n", "<leader>de", function() execute_if_dap_active(dapui.eval) end, {silent})
rcarriga added a commit that referenced this issue Nov 3, 2022
@rcarriga
Copy link
Owner

rcarriga commented Nov 3, 2022

Yeah makes sense 👍 Added a notification too

@elagil
Copy link
Author

elagil commented Nov 3, 2022

That's great! Thanks for implementing this.

@elagil elagil closed this as completed Nov 3, 2022
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