Skip to content

Commit 31e1ece

Browse files
authored
Stop terminating "attached" debugees when exiting Vim (#1024)
If connecting to a process that's started externally, nvim shouldn't terminate the process on exit.
1 parent fe15b35 commit 31e1ece

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,12 +1034,16 @@ 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+
end
10421042
end
1043+
vim.wait(500, function()
1044+
---@diagnostic disable-next-line: redundant-return-value
1045+
return session == nil and next(sessions) == nil
1046+
end)
10431047
M.repl.close()
10441048
end
10451049

0 commit comments

Comments
 (0)