Skip to content

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)

@mfussenegger mfussenegger force-pushed the disconnect-on-vim-exit branch from 96a2026 to b374cbe Compare August 31, 2023 09:20
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 force-pushed the disconnect-on-vim-exit branch from b374cbe to c9e86d2 Compare August 31, 2023 09:21
@mfussenegger mfussenegger merged commit 31e1ece into mfussenegger:master Aug 31, 2023
@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