From c7474e2dc18f592b2b8bf7fcbfb44f4400c4d2b9 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Thu, 26 Oct 2023 15:30:25 -0700 Subject: [PATCH] Show Dynamic Configuration Providers with No Context This PR adds support to show dynamic configurations when a file is not selected. The changes introduces a new method to the Debugger class called hasDynamicConfigurationProviders. It utilizes the existing ConfigurationManager.hasDebugConfigurationProvider but passing Dynamic TiggerKind instead of Initial. --- .../workbench/contrib/debug/browser/debugAdapterManager.ts | 3 ++- src/vs/workbench/contrib/debug/common/debug.ts | 2 +- src/vs/workbench/contrib/debug/common/debugger.ts | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/debugAdapterManager.ts b/src/vs/workbench/contrib/debug/browser/debugAdapterManager.ts index 55314e58a470f..423316207be93 100644 --- a/src/vs/workbench/contrib/debug/browser/debugAdapterManager.ts +++ b/src/vs/workbench/contrib/debug/browser/debugAdapterManager.ts @@ -341,9 +341,10 @@ export class AdapterManager extends Disposable implements IAdapterManager { // Or if a breakpoint can be set in the current file (good hint that an extension can handle it) if ((!languageLabel || gettingConfigurations || (model && this.canSetBreakpointsIn(model))) && candidates.length === 0) { await this.activateDebuggers('onDebugInitialConfigurations'); + candidates = this.debuggers .filter(a => a.enabled) - .filter(dbg => dbg.hasInitialConfiguration() || dbg.hasConfigurationProvider()); + .filter(dbg => dbg.hasInitialConfiguration() || dbg.hasDynamicConfigurationProviders() || dbg.hasConfigurationProvider()); } if (candidates.length === 0 && languageLabel) { diff --git a/src/vs/workbench/contrib/debug/common/debug.ts b/src/vs/workbench/contrib/debug/common/debug.ts index d55bda40b2618..7b82c2fe9ac80 100644 --- a/src/vs/workbench/contrib/debug/common/debug.ts +++ b/src/vs/workbench/contrib/debug/common/debug.ts @@ -904,7 +904,7 @@ export interface IConfigurationManager { */ onDidSelectConfiguration: Event; - hasDebugConfigurationProvider(debugType: string): boolean; + hasDebugConfigurationProvider(debugType: string, triggerKind?: DebugConfigurationProviderTriggerKind): boolean; getDynamicProviders(): Promise<{ label: string; type: string; pick: () => Promise<{ launch: ILaunch; config: IConfig } | undefined> }[]>; registerDebugConfigurationProvider(debugConfigurationProvider: IDebugConfigurationProvider): IDisposable; diff --git a/src/vs/workbench/contrib/debug/common/debugger.ts b/src/vs/workbench/contrib/debug/common/debugger.ts index e18a400fe91d5..da2de14c24936 100644 --- a/src/vs/workbench/contrib/debug/common/debugger.ts +++ b/src/vs/workbench/contrib/debug/common/debugger.ts @@ -7,7 +7,7 @@ import * as nls from 'vs/nls'; import { isObject } from 'vs/base/common/types'; import { IJSONSchema, IJSONSchemaMap, IJSONSchemaSnippet } from 'vs/base/common/jsonSchema'; import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; -import { IConfig, IDebuggerContribution, IDebugAdapter, IDebugger, IDebugSession, IAdapterManager, IDebugService, debuggerDisabledMessage, IDebuggerMetadata } from 'vs/workbench/contrib/debug/common/debug'; +import { IConfig, IDebuggerContribution, IDebugAdapter, IDebugger, IDebugSession, IAdapterManager, IDebugService, debuggerDisabledMessage, IDebuggerMetadata, DebugConfigurationProviderTriggerKind } from 'vs/workbench/contrib/debug/common/debug'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; import * as ConfigurationResolverUtils from 'vs/workbench/services/configurationResolver/common/configurationResolverUtils'; @@ -176,6 +176,10 @@ export class Debugger implements IDebugger, IDebuggerMetadata { return !!this.debuggerContribution.initialConfigurations; } + hasDynamicConfigurationProviders(): boolean { + return this.debugService.getConfigurationManager().hasDebugConfigurationProvider(this.type, DebugConfigurationProviderTriggerKind.Dynamic); + } + hasConfigurationProvider(): boolean { return this.debugService.getConfigurationManager().hasDebugConfigurationProvider(this.type); }