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

Stop terminating "attached" debugees when exiting Vim #1024

Merged
merged 2 commits into from
Aug 31, 2023

Conversation

NSteinhoff
Copy link
Contributor

Hi,

I mostly use DAP to debug a long-running server process. My workflow has me closing Vim frequently, and whenever I do without remembering to disconnect the debugger, I accidentally terminate the server. Is that intended behavior? Why would DAP want to manage the lifecycle of an "attached" debugee?

Anyways, this hack seems to fix it for me. This was the smallest change I could think of, but it's a breaking change. Perhaps it would be better placed as a per configuration option (terminate_on_vim_exit = false or on_vim_exit = "terminate" | "disconnect"), which defaults to termination, but allows opting out?

I'm not particularly attached to any of this. Take it or leave it, or modify it as you see fit :)

Thanks for your work on this plugin 👍

Copy link
Owner

@mfussenegger mfussenegger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be okay to make this change.

At least I currently can't think of a scenario where this would leak a process also created by nvim-dap, but I may be missing something obvious.

In any case, maybe worth a try. If somebody complains it can still be reverted.
(And in that case, you could try adding a QuitPre autocommand that disconnects. If by the time ExitPre fires the session is already gone, nvim-dap won't terminate it)

lua/dap.lua Outdated Show resolved Hide resolved
NSteinhoff and others added 2 commits August 31, 2023 11:21
When attaching to an already running process, you typically want to
temporarily inspect the process, but you do not want to manage the
process' lifetime. The exit callback currently terminates all sessions
and their debugees.

    autocmd ExitPre * lua require('dap')._vim_exit_handler()

This commit changes the exit handler such that it disconnects from
"attached" debugees without terminating them.
Co-authored-by: Mathias Fußenegger <[email protected]>
@mfussenegger mfussenegger merged commit 31e1ece into mfussenegger:master Aug 31, 2023
4 checks passed
@NSteinhoff NSteinhoff deleted the disconnect-on-vim-exit branch September 4, 2023 08:32
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

Successfully merging this pull request may close these issues.

2 participants