Skip to content

Commit 552af97

Browse files
committed
Add a welcomeView message when no debugger extensions are enabled
Fix microsoft#136450
1 parent 8a4ddd5 commit 552af97

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ import { Extensions as JSONExtensions, IJSONContributionRegistry } from 'vs/plat
2222
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
2323
import { Registry } from 'vs/platform/registry/common/platform';
2424
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
25-
import { CONTEXT_DEBUGGERS_AVAILABLE, IAdapterDescriptor, IAdapterManager, IConfig, IDebugAdapter, IDebugAdapterDescriptorFactory, IDebugAdapterFactory, IDebugConfiguration, IDebugSession, INTERNAL_CONSOLE_OPTIONS_SCHEMA } from 'vs/workbench/contrib/debug/common/debug';
25+
import { CONTEXT_DEBUGGERS_AVAILABLE, CONTEXT_DEBUG_EXTENSION_AVAILABLE, IAdapterDescriptor, IAdapterManager, IConfig, IDebugAdapter, IDebugAdapterDescriptorFactory, IDebugAdapterFactory, IDebugConfiguration, IDebugSession, INTERNAL_CONSOLE_OPTIONS_SCHEMA } from 'vs/workbench/contrib/debug/common/debug';
2626
import { Debugger } from 'vs/workbench/contrib/debug/common/debugger';
2727
import { breakpointsExtPoint, debuggersExtPoint, launchSchema, presentationSchema } from 'vs/workbench/contrib/debug/common/debugSchemas';
2828
import { TaskDefinitionRegistry } from 'vs/workbench/contrib/tasks/common/taskDefinitionRegistry';
2929
import { launchSchemaId } from 'vs/workbench/services/configuration/common/configuration';
3030
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
3131
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
32+
import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
3233

3334
const jsonRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
3435

@@ -38,6 +39,7 @@ export class AdapterManager extends Disposable implements IAdapterManager {
3839
private adapterDescriptorFactories: IDebugAdapterDescriptorFactory[];
3940
private debugAdapterFactories = new Map<string, IDebugAdapterFactory>();
4041
private debuggersAvailable: IContextKey<boolean>;
42+
private debugExtensionsAvailable: IContextKey<boolean>;
4143
private readonly _onDidRegisterDebugger = new Emitter<void>();
4244
private readonly _onDidDebuggersExtPointRead = new Emitter<void>();
4345
private breakpointModeIdsSet = new Set<string>();
@@ -53,6 +55,7 @@ export class AdapterManager extends Disposable implements IAdapterManager {
5355
@IContextKeyService private readonly contextKeyService: IContextKeyService,
5456
@IModeService private readonly modeService: IModeService,
5557
@IDialogService private readonly dialogService: IDialogService,
58+
@ILifecycleService private readonly lifecycleService: ILifecycleService,
5659
) {
5760
super();
5861
this.adapterDescriptorFactories = [];
@@ -64,6 +67,13 @@ export class AdapterManager extends Disposable implements IAdapterManager {
6467
this.debuggersAvailable.set(this.hasEnabledDebuggers());
6568
}
6669
}));
70+
this.debugExtensionsAvailable = CONTEXT_DEBUG_EXTENSION_AVAILABLE.bindTo(contextKeyService);
71+
this.debugExtensionsAvailable.set(true); // Avoid a flash of the default message before extensions load.
72+
this._register(this.onDidDebuggersExtPointRead(() => {
73+
this.debugExtensionsAvailable.set(this.debuggers.length > 0);
74+
}));
75+
this.lifecycleService.when(LifecyclePhase.Eventually)
76+
.then(() => this.debugExtensionsAvailable.set(this.debuggers.length > 0)); // If no extensions with a debugger contribution are loaded
6777
}
6878

6979
private registerListeners(): void {

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
1010
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1111
import { IContextKeyService, RawContextKey, IContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
1212
import { localize } from 'vs/nls';
13-
import { IDebugService, CONTEXT_DEBUGGERS_AVAILABLE } from 'vs/workbench/contrib/debug/common/debug';
13+
import { IDebugService, CONTEXT_DEBUGGERS_AVAILABLE, CONTEXT_DEBUG_EXTENSION_AVAILABLE } from 'vs/workbench/contrib/debug/common/debug';
1414
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
1515
import { ViewPane } from 'vs/workbench/browser/parts/views/viewPane';
1616
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@@ -142,3 +142,9 @@ viewsRegistry.registerViewWelcomeContent(WelcomeView.ID, {
142142
when: ContextKeyExpr.and(CONTEXT_DEBUGGERS_AVAILABLE, WorkbenchStateContext.isEqualTo('empty')),
143143
group: ViewContentGroups.Debug
144144
});
145+
146+
viewsRegistry.registerViewWelcomeContent(WelcomeView.ID, {
147+
content: localize('allDebuggersDisabled', "All debug extensions are disabled. Enable a debug extension or install a new one from the Marketplace."),
148+
when: CONTEXT_DEBUG_EXTENSION_AVAILABLE.toNegated(),
149+
group: ViewContentGroups.Debug
150+
});

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export const CONTEXT_JUMP_TO_CURSOR_SUPPORTED = new RawContextKey<boolean>('jump
7171
export const CONTEXT_STEP_INTO_TARGETS_SUPPORTED = new RawContextKey<boolean>('stepIntoTargetsSupported', false, { type: 'boolean', description: nls.localize('stepIntoTargetsSupported', "True when the focused session supports 'stepIntoTargets' request.") });
7272
export const CONTEXT_BREAKPOINTS_EXIST = new RawContextKey<boolean>('breakpointsExist', false, { type: 'boolean', description: nls.localize('breakpointsExist', "True when at least one breakpoint exists.") });
7373
export const CONTEXT_DEBUGGERS_AVAILABLE = new RawContextKey<boolean>('debuggersAvailable', false, { type: 'boolean', description: nls.localize('debuggersAvailable', "True when there is at least one debug extensions active.") });
74+
export const CONTEXT_DEBUG_EXTENSION_AVAILABLE = new RawContextKey<boolean>('debugExtensionAvailable', false, { type: 'boolean', description: nls.localize('debugExtensionsAvailable', "True when there is at least one debug extension installed and enabled.") });
7475
export const CONTEXT_DEBUG_PROTOCOL_VARIABLE_MENU_CONTEXT = new RawContextKey<string>('debugProtocolVariableMenuContext', undefined, { type: 'string', description: nls.localize('debugProtocolVariableMenuContext', "Represents the context the debug adapter sets on the focused variable in the VARIABLES view.") });
7576
export const CONTEXT_SET_VARIABLE_SUPPORTED = new RawContextKey<boolean>('debugSetVariableSupported', false, { type: 'boolean', description: nls.localize('debugSetVariableSupported', "True when the focused session supports 'setVariable' request.") });
7677
export const CONTEXT_SET_EXPRESSION_SUPPORTED = new RawContextKey<boolean>('debugSetExpressionSupported', false, { type: 'boolean', description: nls.localize('debugSetExpressionSupported', "True when the focused session supports 'setExpression' request.") });

0 commit comments

Comments
 (0)