Skip to content

Commit 3d18bf9

Browse files
committed
Stop terminating "attached" debugees
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.
1 parent 4377a05 commit 3d18bf9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lua/dap.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,11 +1034,15 @@ end
10341034

10351035
function M._vim_exit_handler()
10361036
for _, s in pairs(sessions) do
1037-
terminate(s)
1038-
vim.wait(500, function()
1039-
---@diagnostic disable-next-line: redundant-return-value
1040-
return session == nil and next(sessions) == nil
1041-
end)
1037+
if s.config.request == "attach" then
1038+
s:disconnect({ terminateDebuggee = false })
1039+
else
1040+
terminate(s)
1041+
vim.wait(500, function()
1042+
---@diagnostic disable-next-line: redundant-return-value
1043+
return session == nil and next(sessions) == nil
1044+
end)
1045+
end
10421046
end
10431047
M.repl.close()
10441048
end

0 commit comments

Comments
 (0)