Skip to content

Commit d21c749

Browse files
authored
Load breakpoint widget keybinding labels dynamically (microsoft#186758)
* Load breakpoint widget keybinding labels dynamically * Set defaults
1 parent 23383fa commit d21c749

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { IEditorOptions, EditorOption } from 'vs/editor/common/config/editorOpti
3939
import { PLAINTEXT_LANGUAGE_ID } from 'vs/editor/common/languages/modesRegistry';
4040
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
4141
import { defaultSelectBoxStyles } from 'vs/platform/theme/browser/defaultStyles';
42+
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
4243

4344
const $ = dom.$;
4445
const IPrivateBreakpointWidgetService = createDecorator<IPrivateBreakpointWidgetService>('privateBreakpointWidgetService');
@@ -96,6 +97,7 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
9697
@ICodeEditorService private readonly codeEditorService: ICodeEditorService,
9798
@IConfigurationService private readonly _configurationService: IConfigurationService,
9899
@ILanguageFeaturesService private readonly languageFeaturesService: ILanguageFeaturesService,
100+
@IKeybindingService private readonly keybindingService: IKeybindingService,
99101
) {
100102
super(editor, { showFrame: true, showArrow: false, frameWidth: 1, isAccessible: true });
101103

@@ -130,13 +132,15 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
130132
}
131133

132134
private get placeholder(): string {
135+
const acceptString = this.keybindingService.lookupKeybinding(AcceptBreakpointWidgetInputAction.ID)?.getLabel() || 'Enter';
136+
const closeString = this.keybindingService.lookupKeybinding(CloseBreakpointWidgetCommand.ID)?.getLabel() || 'Escape';
133137
switch (this.context) {
134138
case Context.LOG_MESSAGE:
135-
return nls.localize('breakpointWidgetLogMessagePlaceholder', "Message to log when breakpoint is hit. Expressions within {} are interpolated. 'Enter' to accept, 'Esc' to cancel.");
139+
return nls.localize('breakpointWidgetLogMessagePlaceholder', "Message to log when breakpoint is hit. Expressions within {} are interpolated. '{0}' to accept, '{1}' to cancel.", acceptString, closeString);
136140
case Context.HIT_COUNT:
137-
return nls.localize('breakpointWidgetHitCountPlaceholder', "Break when hit count condition is met. 'Enter' to accept, 'Esc' to cancel.");
141+
return nls.localize('breakpointWidgetHitCountPlaceholder', "Break when hit count condition is met. '{0}' to accept, '{1}' to cancel.", acceptString, closeString);
138142
default:
139-
return nls.localize('breakpointWidgetExpressionPlaceholder', "Break when expression evaluates to true. 'Enter' to accept, 'Esc' to cancel.");
143+
return nls.localize('breakpointWidgetExpressionPlaceholder', "Break when expression evaluates to true. '{0}' to accept, '{1}' to cancel.", acceptString, closeString);
140144
}
141145
}
142146

@@ -364,10 +368,10 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
364368
}
365369

366370
class AcceptBreakpointWidgetInputAction extends EditorCommand {
367-
371+
static ID = 'breakpointWidget.action.acceptInput';
368372
constructor() {
369373
super({
370-
id: 'breakpointWidget.action.acceptInput',
374+
id: AcceptBreakpointWidgetInputAction.ID,
371375
precondition: CONTEXT_BREAKPOINT_WIDGET_VISIBLE,
372376
kbOpts: {
373377
kbExpr: CONTEXT_IN_BREAKPOINT_WIDGET,
@@ -383,10 +387,10 @@ class AcceptBreakpointWidgetInputAction extends EditorCommand {
383387
}
384388

385389
class CloseBreakpointWidgetCommand extends EditorCommand {
386-
390+
static ID = 'closeBreakpointWidget';
387391
constructor() {
388392
super({
389-
id: 'closeBreakpointWidget',
393+
id: CloseBreakpointWidgetCommand.ID,
390394
precondition: CONTEXT_BREAKPOINT_WIDGET_VISIBLE,
391395
kbOpts: {
392396
kbExpr: EditorContextKeys.textInputFocus,

0 commit comments

Comments
 (0)