server-ready: support debugWithEdge as well as debugWithChrome

This commit is contained in:
Connor Peet 2021-05-07 12:02:36 -07:00
parent 244eccdbcc
commit 54ce4a405e
No known key found for this signature in database
GPG key ID: CF8FD2EA0DBC61BD
2 changed files with 23 additions and 11 deletions

View file

@ -69,19 +69,23 @@
"additionalProperties": false,
"markdownDescription": "%debug.server.ready.serverReadyAction.description%",
"default": {
"action": "openExternally"
"action": "debugWithEdge",
"pattern": "listening on port ([0-9]+)",
"uriFormat": "http://localhost:%s",
"webRoot": "${workspaceFolder}"
},
"properties": {
"action": {
"type": "string",
"enum": [
"debugWithChrome"
"debugWithChrome",
"debugWithEdge"
],
"enumDescriptions": [
"%debug.server.ready.action.debugWithChrome.description%"
],
"markdownDescription": "%debug.server.ready.action.description%",
"default": "openExternally"
"default": "debugWithEdge"
},
"pattern": {
"type": "string",

View file

@ -16,7 +16,7 @@ const WEB_ROOT = '${workspaceFolder}';
interface ServerReadyAction {
pattern: string;
action?: 'openExternally' | 'debugWithChrome' | 'startDebugging';
action?: 'openExternally' | 'debugWithChrome' | 'debugWithEdge' | 'startDebugging';
uriFormat?: string;
webRoot?: string;
name?: string;
@ -147,13 +147,11 @@ class ServerReadyDetector extends vscode.Disposable {
break;
case 'debugWithChrome':
vscode.debug.startDebugging(session.workspaceFolder, {
type: 'pwa-chrome',
name: 'Chrome Debug',
request: 'launch',
url: uri,
webRoot: args.webRoot || WEB_ROOT
});
this.debugWithBrowser('pwa-chrome', session, uri);
break;
case 'debugWithEdge':
this.debugWithBrowser('pwa-msedge', session, uri);
break;
case 'startDebugging':
@ -165,6 +163,16 @@ class ServerReadyDetector extends vscode.Disposable {
break;
}
}
private debugWithBrowser(type: string, session: vscode.DebugSession, uri: string) {
return vscode.debug.startDebugging(session.workspaceFolder, {
type,
name: 'Browser Debug',
request: 'launch',
url: uri,
webRoot: session.configuration.serverReadyAction.webRoot || WEB_ROOT
});
}
}
export function activate(context: vscode.ExtensionContext) {