Skip to content

Commit 9b4a8d6

Browse files
authored
debug: handle runtime-registered dynamic config providers (microsoft#201030)
Fixes microsoft#198800
1 parent d6cef87 commit 9b4a8d6

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

src/vs/workbench/contrib/debug/browser/debugActionViewItems.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,16 @@ export class StartDebugActionViewItem extends BaseActionViewItem {
130130
selectBoxContainer.style.borderLeft = `1px solid ${asCssVariable(selectBorder)}`;
131131
this.container.style.backgroundColor = asCssVariable(selectBackground);
132132

133-
this.debugService.getConfigurationManager().getDynamicProviders().then(providers => {
134-
this.providers = providers;
135-
if (this.providers.length > 0) {
133+
const configManager = this.debugService.getConfigurationManager();
134+
const updateDynamicConfigs = () => configManager.getDynamicProviders().then(providers => {
135+
if (providers.length !== this.providers.length) {
136+
this.providers = providers;
136137
this.updateOptions();
137138
}
138139
});
139140

141+
this.toDispose.push(configManager.onDidChangeConfigurationProviders(updateDynamicConfigs));
142+
updateDynamicConfigs();
140143
this.updateOptions();
141144
}
142145

src/vs/workbench/contrib/debug/browser/debugConfigurationManager.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { IJSONSchema } from 'vs/base/common/jsonSchema';
1212
import { DisposableStore, IDisposable, dispose } from 'vs/base/common/lifecycle';
1313
import * as objects from 'vs/base/common/objects';
1414
import * as resources from 'vs/base/common/resources';
15+
import { ThemeIcon } from 'vs/base/common/themables';
1516
import { URI as uri } from 'vs/base/common/uri';
1617
import * as nls from 'vs/nls';
1718
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -22,7 +23,6 @@ import { IJSONContributionRegistry, Extensions as JSONExtensions } from 'vs/plat
2223
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
2324
import { Registry } from 'vs/platform/registry/common/platform';
2425
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
25-
import { ThemeIcon } from 'vs/base/common/themables';
2626
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
2727
import { IWorkspaceContextService, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, WorkbenchState } from 'vs/platform/workspace/common/workspace';
2828
import { IEditorPane } from 'vs/workbench/common/editor';
@@ -59,6 +59,8 @@ export class ConfigurationManager implements IConfigurationManager {
5959
private readonly _onDidSelectConfigurationName = new Emitter<void>();
6060
private configProviders: IDebugConfigurationProvider[];
6161
private debugConfigurationTypeContext: IContextKey<string>;
62+
private readonly _onDidChangeConfigurationProviders = new Emitter<void>();
63+
public readonly onDidChangeConfigurationProviders = this._onDidChangeConfigurationProviders.event;
6264

6365
constructor(
6466
private readonly adapterManager: IAdapterManager,
@@ -73,7 +75,7 @@ export class ConfigurationManager implements IConfigurationManager {
7375
@IContextKeyService contextKeyService: IContextKeyService
7476
) {
7577
this.configProviders = [];
76-
this.toDispose = [];
78+
this.toDispose = [this._onDidChangeConfigurationProviders];
7779
this.initLaunches();
7880
this.setCompoundSchemaValues();
7981
this.registerListeners();
@@ -92,9 +94,11 @@ export class ConfigurationManager implements IConfigurationManager {
9294

9395
registerDebugConfigurationProvider(debugConfigurationProvider: IDebugConfigurationProvider): IDisposable {
9496
this.configProviders.push(debugConfigurationProvider);
97+
this._onDidChangeConfigurationProviders.fire();
9598
return {
9699
dispose: () => {
97100
this.unregisterDebugConfigurationProvider(debugConfigurationProvider);
101+
this._onDidChangeConfigurationProviders.fire();
98102
}
99103
};
100104
}
@@ -187,18 +191,24 @@ export class ConfigurationManager implements IConfigurationManager {
187191
}
188192

189193
if (explicitTypes.length) {
190-
return acc.concat(explicitTypes);
191-
}
192-
193-
if (hasGenericEvent) {
194+
explicitTypes.forEach(t => acc.add(t));
195+
} else if (hasGenericEvent) {
194196
const debuggerType = e.contributes?.debuggers?.[0].type;
195-
return debuggerType ? acc.concat(debuggerType) : acc;
197+
if (debuggerType) {
198+
acc.add(debuggerType);
199+
}
196200
}
197201

198202
return acc;
199-
}, [] as string[]);
203+
}, new Set<string>());
204+
205+
for (const configProvider of this.configProviders) {
206+
if (configProvider.triggerKind === DebugConfigurationProviderTriggerKind.Dynamic) {
207+
debugDynamicExtensionsTypes.add(configProvider.type);
208+
}
209+
}
200210

201-
return debugDynamicExtensionsTypes.map(type => {
211+
return [...debugDynamicExtensionsTypes].map(type => {
202212
return {
203213
label: this.adapterManager.getDebuggerLabel(type)!,
204214
getProvider: async () => {

src/vs/workbench/contrib/debug/common/debug.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,11 @@ export interface IConfigurationManager {
907907
*/
908908
onDidSelectConfiguration: Event<void>;
909909

910+
/**
911+
* Allows to register on change of selected debug configuration.
912+
*/
913+
onDidChangeConfigurationProviders: Event<void>;
914+
910915
hasDebugConfigurationProvider(debugType: string, triggerKind?: DebugConfigurationProviderTriggerKind): boolean;
911916
getDynamicProviders(): Promise<{ label: string; type: string; pick: () => Promise<{ launch: ILaunch; config: IConfig } | undefined> }[]>;
912917

0 commit comments

Comments
 (0)