From fedcd8648b9583fbfb2933b5013fcf2c61ff6339 Mon Sep 17 00:00:00 2001 From: isidor Date: Wed, 24 Jan 2018 17:14:06 +0100 Subject: [PATCH] debug: allow scoping of configurations inside compounds fixes #38134 --- src/vs/workbench/parts/debug/common/debug.ts | 2 +- .../debugConfigurationManager.ts | 13 +++++++- .../debug/electron-browser/debugService.ts | 30 ++++++++++++------- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/vs/workbench/parts/debug/common/debug.ts b/src/vs/workbench/parts/debug/common/debug.ts index 598c69684af..2abec2b2d2a 100644 --- a/src/vs/workbench/parts/debug/common/debug.ts +++ b/src/vs/workbench/parts/debug/common/debug.ts @@ -363,7 +363,7 @@ export interface IConfig extends IEnvConfig { export interface ICompound { name: string; - configurations: string[]; + configurations: (string | { name: string, folder: string })[]; } export interface IAdapterExecutable { diff --git a/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts b/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts index a9a6226e949..34b56d52c49 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts @@ -191,7 +191,18 @@ const schema: IJSONSchema = { enum: [], description: nls.localize('useUniqueNames', "Please use unique configuration names.") }, { - type: 'object' + type: 'object', + required: ['name'], + properties: { + name: { + type: 'string', + description: nls.localize('app.launch.json.compound.name', "Name of compound. Appears in the launch configuration drop down menu.") + }, + folder: { + type: 'string', + description: nls.localize('app.launch.json.compound.folder', "Name of folder in which the compound is located.") + } + } }] }, description: nls.localize('app.launch.json.compounds.configurations', "Names of configurations that will be started as part of this compound.") diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index ebe3ccf93d6..28815b8c5d0 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -693,21 +693,31 @@ export class DebugService implements debug.IDebugService { "Compound must have \"configurations\" attribute set in order to start multiple configurations."))); } - return sequence(compound.configurations.map(name => () => { + return TPromise.join(compound.configurations.map(configData => { + const name = typeof configData === 'string' ? configData : configData.name; if (name === compound.name) { return TPromise.as(null); } let rootForName: IWorkspaceFolder; - const launchesContainingName = this.configurationManager.getLaunches().filter(l => !!l.getConfiguration(name)); - if (launchesContainingName.length === 1) { - rootForName = launchesContainingName[0].workspace; - } else if (launchesContainingName.length > 1 && launchesContainingName.indexOf(launch) >= 0) { - // If there are multiple launches containing the configuration give priority to the configuration in the current launch - rootForName = launch.workspace; - } else { - return TPromise.wrapError(new Error(launchesContainingName.length === 0 ? nls.localize('noConfigurationNameInWorkspace', "Could not find launch configuration '{0}' in the workspace.", name) - : nls.localize('multipleConfigurationNamesInWorkspace', "There are multiple launch configurates `{0}` in the workspace. Use folder name to qualify the configuration.", name))); + if (typeof configData === 'string') { + const launchesContainingName = this.configurationManager.getLaunches().filter(l => !!l.getConfiguration(name)); + if (launchesContainingName.length === 1) { + rootForName = launchesContainingName[0].workspace; + } else if (launchesContainingName.length > 1 && launchesContainingName.indexOf(launch) >= 0) { + // If there are multiple launches containing the configuration give priority to the configuration in the current launch + rootForName = launch.workspace; + } else { + return TPromise.wrapError(new Error(launchesContainingName.length === 0 ? nls.localize('noConfigurationNameInWorkspace', "Could not find launch configuration '{0}' in the workspace.", name) + : nls.localize('multipleConfigurationNamesInWorkspace', "There are multiple launch configurates `{0}` in the workspace. Use folder name to qualify the configuration.", name))); + } + } else if (configData.folder) { + const root = this.contextService.getWorkspace().folders.filter(f => f.name === configData.folder).pop(); + if (root) { + rootForName = root; + } else { + return TPromise.wrapError(new Error(nls.localize('noFolderWithName', "Can not find folder with name '{0}' for configuration '{1}' in compound '{2}'.", configData.folder, configData.name, compound.name))); + } } return this.startDebugging(rootForName, name, noDebug, topCompoundName || compound.name); -- GitLab