diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 39abad445aa..3606de8cb27 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -121,4 +121,16 @@ declare module 'vscode' { */ export function registerDiffInformationCommand(command: string, callback: (diff: LineChange[], ...args: any[]) => any, thisArg?: any): Disposable; } + + export namespace debug { + + /** + * Start debugging by using either a named launch or named compound configuration, + * or by directly passing a DebugConfiguration. + * Before debugging starts, all unsaved files are saved and the launch configurations are up-to-date. + * @param nameOrConfiguration Either the name of a debug or compound configuration or a DebugConfiguration object. + * @return A thenable that resolves when debugging could be successfully started. + */ + export function startDebugging(nameOrConfiguration: string | DebugConfiguration): Thenable; + } } diff --git a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts index 8f85bd5312c..8177021316c 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts @@ -44,6 +44,19 @@ export class MainThreadDebugService extends MainThreadDebugServiceShape { this._toDispose = dispose(this._toDispose); } + public $startDebugging(nameOrConfiguration: string | IConfig): TPromise { + + if (typeof nameOrConfiguration === 'string') { + return this.debugService.startDebugging(nameOrConfiguration).then(x => { + return true; + }, err => { + return TPromise.wrapError(err && err.message ? err.message : 'cannot start debugging'); + }); + } else { + return TPromise.wrapError(new Error('startDebugging with configuration object not yet implemented')); + } + } + public $startDebugSession(configuration: IConfig): TPromise { if (configuration.request !== 'launch' && configuration.request !== 'attach') { return TPromise.wrapError(new Error(`only 'launch' or 'attach' allowed for 'request' attribute`)); diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 727328a3db1..561cabb4116 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -467,6 +467,9 @@ export function createApiFactory( get activeDebugSession() { return extHostDebugService.activeDebugSession; }, + startDebugging: proposedApiFunction(extension, (nameOrConfig: string | vscode.DebugConfiguration) => { + return extHostDebugService.startDebugging(nameOrConfig); + }), startDebugSession(config: vscode.DebugConfiguration) { return extHostDebugService.startDebugSession(config); }, diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 8425a69ad20..2700b733366 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -345,6 +345,7 @@ export abstract class MainThreadSCMShape { export type DebugSessionUUID = string; export abstract class MainThreadDebugServiceShape { + $startDebugging(nameOrConfig: string | vscode.DebugConfiguration): TPromise { throw ni(); } $startDebugSession(config: vscode.DebugConfiguration): TPromise { throw ni(); } $customDebugAdapterRequest(id: DebugSessionUUID, command: string, args: any): TPromise { throw ni(); } } diff --git a/src/vs/workbench/api/node/extHostDebugService.ts b/src/vs/workbench/api/node/extHostDebugService.ts index 8ff6c387d7c..b9dc8d8b7e3 100644 --- a/src/vs/workbench/api/node/extHostDebugService.ts +++ b/src/vs/workbench/api/node/extHostDebugService.ts @@ -45,6 +45,11 @@ export class ExtHostDebugService extends ExtHostDebugServiceShape { this._debugServiceProxy = threadService.get(MainContext.MainThreadDebugService); } + public startDebugging(nameOrConfig: string | vscode.DebugConfiguration): TPromise { + + return this._debugServiceProxy.$startDebugging(nameOrConfig); + } + public startDebugSession(config: vscode.DebugConfiguration): TPromise { return this._debugServiceProxy.$startDebugSession(config).then((id: DebugSessionUUID) => {