debug: allow serverReadyAction to run a launch config by name

https://github.com/microsoft/vscode/issues/109931
This commit is contained in:
Connor Peet 2020-11-03 09:59:30 -08:00
parent 57340b736b
commit ab9bb823ea
No known key found for this signature in database
GPG key ID: CF8FD2EA0DBC61BD
3 changed files with 43 additions and 5 deletions

View file

@ -39,8 +39,7 @@
"openExternally"
],
"enumDescriptions": [
"%debug.server.ready.action.openExternally.description%",
"%debug.server.ready.action.debugWithChrome.description%"
"%debug.server.ready.action.openExternally.description%"
],
"markdownDescription": "%debug.server.ready.action.description%",
"default": "openExternally"
@ -71,7 +70,6 @@
"debugWithChrome"
],
"enumDescriptions": [
"%debug.server.ready.action.openExternally.description%",
"%debug.server.ready.action.debugWithChrome.description%"
],
"markdownDescription": "%debug.server.ready.action.description%",
@ -93,6 +91,39 @@
"default": "${workspaceFolder}"
}
}
},
{
"type": "object",
"additionalProperties": false,
"markdownDescription": "%debug.server.ready.serverReadyAction.description%",
"default": {
"action": "startDebugging",
"name": "<launch browser config name>"
},
"required": ["name"],
"properties": {
"action": {
"type": "string",
"enum": [
"startDebugging"
],
"enumDescriptions": [
"%debug.server.ready.action.startDebugging.description%"
],
"markdownDescription": "%debug.server.ready.action.description%",
"default": "startDebugging"
},
"pattern": {
"type": "string",
"markdownDescription": "%debug.server.ready.pattern.description%",
"default": "listening on port ([0-9]+)"
},
"name": {
"type": "string",
"markdownDescription": "%debug.server.ready.debugConfigName.description%",
"default": "Launch Browser"
}
}
}
]
}

View file

@ -6,7 +6,9 @@
"debug.server.ready.action.description": "What to do with the URI when the server is ready.",
"debug.server.ready.action.openExternally.description": "Open URI externally with the default application.",
"debug.server.ready.action.debugWithChrome.description": "Start debugging with the 'Debugger for Chrome'.",
"debug.server.ready.action.startDebugging.description": "Run another launch configuration.",
"debug.server.ready.pattern.description": "Server is ready if this pattern appears on the debug console. The first capture group must include a URI or a port number.",
"debug.server.ready.uriFormat.description": "A format string used when constructing the URI from a port number. The first '%s' is substituted with the port number.",
"debug.server.ready.webRoot.description": "Value passed to the debug configuration for the 'Debugger for Chrome'."
"debug.server.ready.webRoot.description": "Value passed to the debug configuration for the 'Debugger for Chrome'.",
"debug.server.ready.debugConfigName.description": "Name of the launch configuration to run."
}

View file

@ -16,9 +16,10 @@ const WEB_ROOT = '${workspaceFolder}';
interface ServerReadyAction {
pattern: string;
action?: 'openExternally' | 'debugWithChrome';
action?: 'openExternally' | 'debugWithChrome' | 'startDebugging';
uriFormat?: string;
webRoot?: string;
name?: string;
}
class ServerReadyDetector extends vscode.Disposable {
@ -155,6 +156,10 @@ class ServerReadyDetector extends vscode.Disposable {
});
break;
case 'startDebugging':
vscode.debug.startDebugging(session.workspaceFolder, args.name || 'unspecified');
break;
default:
// not supported
break;