feat: don't attach debugger to terminal until a process starts #221
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As referenced in #199, the debugger terminal experience today is awkward
in that a session is 'running' as long as the terminal is open, even
when no Node.js processes are currently active. This PR addresses that.
We reuse the
TerminalNodeLauncher
to set up the terminal, but do sooutside of the debug adapter. Instead, when we see a process launches
and enters debug mode, we register it inside of a 'delegate' collection,
and then send the delegate ID into
vscode.debug.startDebugging
. Thispulls up the debug session as if it was just launched insider the
adapter, and from then on it's identical to any other debug session.
This PR also adds an configuration option that configures the default
launch config used for the debugger terminal, and there's churn from
typing the
targetOrigin
away fromany
throughout the process, nowthat I've fully internalized what it is and what it's used for :)
This implementation has some indirection, but within the adapter's
architecture I believe this is the best general approach. Due to the way
in which we launch processes and the way the VS Code terminal behaves
(both of which are optimal), we can't ever know that we have a
debuggable target exists until it knocks on our door with a CDP
connection. At that point, we need to delegate it into a debug session
in some form or another. That's what I've tried to do here with a
minimal amount of changes or knowledge-leaks into the rest of the code.
Fixes #199