Skip to content

Commit

Permalink
address pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
connor4312 committed Jan 5, 2023
1 parent 990a496 commit 1bcbb11
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions src/vs/workbench/contrib/debug/browser/debugConfigurationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,34 +119,25 @@ export class ConfigurationManager implements IConfigurationManager {
}

async resolveConfigurationByProviders(folderUri: uri | undefined, type: string | undefined, config: IConfig, token: CancellationToken): Promise<IConfig | null | undefined> {
// activate debuggers early for the provided type in case any '*' typed debug configuration providers are activated
// based on the provided type.
await this.adapterManager.activateDebuggers('onDebugResolve', type);
const anyTypeProviders = this.configProviders.filter(p => p.type === '*' && p.resolveDebugConfiguration);

const resolveDebugConfigurationForType = async (type: string | undefined, config: IConfig | null | undefined) => {
await this.adapterManager.activateDebuggers('onDebugResolve', type);
// pipe the config through the promises sequentially. Append at the end the '*' types
const providers = this.configProviders.filter(p => p.type === type && p.resolveDebugConfiguration)
.concat(anyTypeProviders);

let result: IConfig | null | undefined = config;
await sequence(providers.map(provider => async () => {
// If any provider returned undefined or null make sure to respect that and do not pass the result to more resolver
if (result) {
result = await provider.resolveDebugConfiguration!(folderUri, result, token);
}
}));
return result;
};
if (type !== '*') {
await this.adapterManager.activateDebuggers('onDebugResolve', type);
}

let result = await resolveDebugConfigurationForType(type, config);
const seenTypes = new Set<string | undefined>().add(type);
for (const p of this.configProviders) {
if (p.type === type && p.resolveDebugConfiguration && config) {
config = await p.resolveDebugConfiguration(folderUri, config, token);
}
}

while (result && !seenTypes.has(result.type)) {
seenTypes.add(result.type);
return config;
};

let result: IConfig | null | undefined = config;
for (let seen = new Set(); result && !seen.has(result.type);) {
seen.add(result?.type);
result = await resolveDebugConfigurationForType(result.type, result);
result = await resolveDebugConfigurationForType('*', result);
}

return result;
Expand Down

0 comments on commit 1bcbb11

Please sign in to comment.