diff --git a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts index aed656accd0..c7a0ba78a06 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts @@ -177,8 +177,8 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape { } public $startDebugging(_folderUri: uri | undefined, nameOrConfiguration: string | IConfig): TPromise { - const folderUriString = _folderUri ? uri.revive(_folderUri).toString() : undefined; - const launch = folderUriString ? this.debugService.getConfigurationManager().getLaunches().filter(l => l.workspace && l.workspace.uri.toString() === folderUriString).pop() : undefined; + const folderUri = _folderUri ? uri.revive(_folderUri) : undefined; + const launch = this.debugService.getConfigurationManager().getLaunch(folderUri); return this.debugService.startDebugging(launch, nameOrConfiguration).then(x => { return true; }, err => { diff --git a/src/vs/workbench/parts/debug/browser/debugActionItems.ts b/src/vs/workbench/parts/debug/browser/debugActionItems.ts index 4d6367248ac..14ab35e5986 100644 --- a/src/vs/workbench/parts/debug/browser/debugActionItems.ts +++ b/src/vs/workbench/parts/debug/browser/debugActionItems.ts @@ -156,7 +156,7 @@ export class StartDebugActionItem implements IActionItem { const manager = this.debugService.getConfigurationManager(); const launches = manager.getLaunches(); const inWorkspace = this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE; - manager.getLaunches().forEach(launch => + launches.forEach(launch => launch.getConfigurationNames().forEach(name => { if (name === manager.selectedConfiguration.name && launch === manager.selectedConfiguration.launch) { this.selected = this.options.length; diff --git a/src/vs/workbench/parts/debug/common/debug.ts b/src/vs/workbench/parts/debug/common/debug.ts index 164cad54b53..7ba05b9040d 100644 --- a/src/vs/workbench/parts/debug/common/debug.ts +++ b/src/vs/workbench/parts/debug/common/debug.ts @@ -429,6 +429,8 @@ export interface IConfigurationManager { getLaunches(): ILaunch[]; + getLaunch(workspaceUri: uri): ILaunch | undefined; + /** * Allows to register on change of selected debug configuration. */ diff --git a/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts b/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts index adcdcc16cf2..ec04698d860 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts @@ -390,6 +390,14 @@ export class ConfigurationManager implements IConfigurationManager { return this.launches; } + public getLaunch(workspaceUri: uri): ILaunch { + if (!uri.isUri(workspaceUri)) { + return undefined; + } + + return this.launches.filter(l => l.workspace && l.workspace.uri.toString() === workspaceUri.toString()).pop(); + } + public get selectedConfiguration(): { launch: ILaunch, name: string } { return { launch: this.selectedLaunch, diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index 065a0fad315..fc3bd185600 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -1061,7 +1061,7 @@ export class DebugService implements debug.IDebugService { // Read the configuration again if a launch.json has been changed, if not just use the inmemory configuration let config = process.configuration; - const launch = this.configurationManager.getLaunches().filter(l => l.workspace && process.session.root && l.workspace.uri.toString() === process.session.root.uri.toString()).pop(); + const launch = process.session.root ? this.configurationManager.getLaunch(process.session.root.uri) : undefined; if (this.launchJsonChanged && launch) { this.launchJsonChanged = false; config = launch.getConfiguration(process.configuration.name) || config;