Skip to content

Commit

Permalink
Add pinning support for dynamic launch configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed May 13, 2020
1 parent 74408ba commit 7edfb1d
Showing 1 changed file with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,27 @@ export class ConfigurationManager implements IConfigurationManager {
picks.push(provider.provideDebugConfigurations!(launch.workspace.uri, token.token).then(configurations => configurations.map(config => ({
label: config.name,
config,
buttons: [{
iconClass: 'codicon-pin',
tooltip: nls.localize('pinLaunchConfig', "Pin Launch Configuration")
}],
launch
}))));
}
});
const promiseOfPicks = Promise.all(picks).then(result => result.reduce((first, second) => first.concat(second), []));

const result = await this.quickInputService.pick<{ label: string, launch: ILaunch, config: IConfig }>(promiseOfPicks, { placeHolder: nls.localize('selectConfiguration', "Select Debug Configuration") });
const result = await this.quickInputService.pick<{ label: string, launch: ILaunch, config: IConfig }>(promiseOfPicks, {
placeHolder: nls.localize('selectConfiguration', "Select Launch Configuration"),
onDidTriggerItemButton: async (context) => {
await this.quickInputService.cancel();
const { launch, config } = context.item;
await launch.openConfigFile(false, config.type);
// Only Launch have a pin trigger button
await (launch as Launch).writeConfiguration(config);
this.selectConfiguration(launch, config.name);
}
});
if (!result) {
// User canceled quick input we should notify the provider to cancel computing configurations
token.cancel();
Expand Down Expand Up @@ -697,6 +711,12 @@ class Launch extends AbstractLaunch implements ILaunch {
created
});
}

async writeConfiguration(configuration: IConfig): Promise<void> {
const fullConfig = objects.deepClone(this.getConfig()!);
fullConfig.configurations.push(configuration);
await this.configurationService.updateValue('launch', fullConfig, { resource: this.workspace.uri }, ConfigurationTarget.WORKSPACE_FOLDER);
}
}

class WorkspaceLaunch extends AbstractLaunch implements ILaunch {
Expand All @@ -718,7 +738,7 @@ class WorkspaceLaunch extends AbstractLaunch implements ILaunch {
}

get name(): string {
return nls.localize('workspace', "Workspace");
return nls.localize('workspace', "workspace");
}

protected getConfig(): IGlobalConfig | undefined {
Expand Down

0 comments on commit 7edfb1d

Please sign in to comment.