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

feat: don't attach debugger to terminal until a process starts #221

Merged
merged 3 commits into from
Jan 15, 2020

Conversation

connor4312
Copy link
Member

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 so
outside 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. This
pulls 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 from any throughout the process, now
that 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

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 so
outside 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`. This
pulls 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 from `any` throughout the process, now
that 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
@connor4312 connor4312 requested a review from roblourens January 10, 2020 21:56
src/build/generate-contributions.ts Outdated Show resolved Hide resolved
}

export interface ICommandTypes {
Copy link
Member

Choose a reason for hiding this comment

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

This is interesting but what's the point of declaring the types here?

Copy link
Member Author

Choose a reason for hiding this comment

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

When dispatching commands between parts of the extension I wanted a way to make sure my types were done up correctly; refactoring some of the commands made me wish that TS could verify my work, so I added these.

@connor4312 connor4312 merged commit 679105b into master Jan 15, 2020
@connor4312 connor4312 deleted the feat/debugger-terminal-sessions branch January 15, 2020 21:04
@connor4312 connor4312 added this to the January 2020 milestone Jan 27, 2020
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.

Don't start a debug session in VS code on initial terminal open
2 participants