-
Notifications
You must be signed in to change notification settings - Fork 28.9k
/
breakpointWidget.ts
563 lines (504 loc) · 23 KB
/
breakpointWidget.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as dom from 'vs/base/browser/dom';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { Button } from 'vs/base/browser/ui/button/button';
import { ISelectOptionItem, SelectBox } from 'vs/base/browser/ui/selectBox/selectBox';
import { CancellationToken } from 'vs/base/common/cancellation';
import { onUnexpectedError } from 'vs/base/common/errors';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import * as lifecycle from 'vs/base/common/lifecycle';
import { URI as uri } from 'vs/base/common/uri';
import 'vs/css!./media/breakpointWidget';
import { IActiveCodeEditor, ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { EditorCommand, ServicesAccessor, registerEditorCommand } from 'vs/editor/browser/editorExtensions';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditor/codeEditorWidget';
import { EditorOption, IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { IPosition, Position } from 'vs/editor/common/core/position';
import { IRange, Range } from 'vs/editor/common/core/range';
import { IDecorationOptions } from 'vs/editor/common/editorCommon';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { CompletionContext, CompletionItemKind, CompletionList } from 'vs/editor/common/languages';
import { PLAINTEXT_LANGUAGE_ID } from 'vs/editor/common/languages/modesRegistry';
import { ITextModel } from 'vs/editor/common/model';
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
import { IModelService } from 'vs/editor/common/services/model';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { CompletionOptions, provideSuggestionItems } from 'vs/editor/contrib/suggest/browser/suggest';
import { ZoneWidget } from 'vs/editor/contrib/zoneWidget/browser/zoneWidget';
import * as nls from 'vs/nls';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IInstantiationService, createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { ILabelService } from 'vs/platform/label/common/label';
import { defaultButtonStyles, defaultSelectBoxStyles } from 'vs/platform/theme/browser/defaultStyles';
import { editorForeground } from 'vs/platform/theme/common/colorRegistry';
import { IColorTheme, IThemeService } from 'vs/platform/theme/common/themeService';
import { getSimpleCodeEditorWidgetOptions, getSimpleEditorOptions } from 'vs/workbench/contrib/codeEditor/browser/simpleEditorOptions';
import { BREAKPOINT_EDITOR_CONTRIBUTION_ID, CONTEXT_BREAKPOINT_WIDGET_VISIBLE, CONTEXT_IN_BREAKPOINT_WIDGET, BreakpointWidgetContext as Context, DEBUG_SCHEME, IBreakpoint, IBreakpointEditorContribution, IBreakpointUpdateData, IDebugService } from 'vs/workbench/contrib/debug/common/debug';
const $ = dom.$;
const IPrivateBreakpointWidgetService = createDecorator<IPrivateBreakpointWidgetService>('privateBreakpointWidgetService');
interface IPrivateBreakpointWidgetService {
readonly _serviceBrand: undefined;
close(success: boolean): void;
}
const DECORATION_KEY = 'breakpointwidgetdecoration';
function isPositionInCurlyBracketBlock(input: IActiveCodeEditor): boolean {
const model = input.getModel();
const bracketPairs = model.bracketPairs.getBracketPairsInRange(Range.fromPositions(input.getPosition()));
return bracketPairs.some(p => p.openingBracketInfo.bracketText === '{');
}
function createDecorations(theme: IColorTheme, placeHolder: string): IDecorationOptions[] {
const transparentForeground = theme.getColor(editorForeground)?.transparent(0.4);
return [{
range: {
startLineNumber: 0,
endLineNumber: 0,
startColumn: 0,
endColumn: 1
},
renderOptions: {
after: {
contentText: placeHolder,
color: transparentForeground ? transparentForeground.toString() : undefined
}
}
}];
}
export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWidgetService {
declare readonly _serviceBrand: undefined;
private selectContainer!: HTMLElement;
private inputContainer!: HTMLElement;
private selectBreakpointContainer!: HTMLElement;
private input!: IActiveCodeEditor;
private selectBreakpointBox!: SelectBox;
private selectModeBox?: SelectBox;
private toDispose: lifecycle.IDisposable[];
private conditionInput = '';
private hitCountInput = '';
private logMessageInput = '';
private modeInput?: DebugProtocol.BreakpointMode;
private breakpoint: IBreakpoint | undefined;
private context: Context;
private heightInPx: number | undefined;
private triggeredByBreakpointInput: IBreakpoint | undefined;
constructor(editor: ICodeEditor, private lineNumber: number, private column: number | undefined, context: Context | undefined,
@IContextViewService private readonly contextViewService: IContextViewService,
@IDebugService private readonly debugService: IDebugService,
@IThemeService private readonly themeService: IThemeService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IModelService private readonly modelService: IModelService,
@ICodeEditorService private readonly codeEditorService: ICodeEditorService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@ILanguageFeaturesService private readonly languageFeaturesService: ILanguageFeaturesService,
@IKeybindingService private readonly keybindingService: IKeybindingService,
@ILabelService private readonly labelService: ILabelService,
@ITextModelService private readonly textModelService: ITextModelService,
) {
super(editor, { showFrame: true, showArrow: false, frameWidth: 1, isAccessible: true });
this.toDispose = [];
const model = this.editor.getModel();
if (model) {
const uri = model.uri;
const breakpoints = this.debugService.getModel().getBreakpoints({ lineNumber: this.lineNumber, column: this.column, uri });
this.breakpoint = breakpoints.length ? breakpoints[0] : undefined;
}
if (context === undefined) {
if (this.breakpoint && !this.breakpoint.condition && !this.breakpoint.hitCondition && this.breakpoint.logMessage) {
this.context = Context.LOG_MESSAGE;
} else if (this.breakpoint && !this.breakpoint.condition && this.breakpoint.hitCondition) {
this.context = Context.HIT_COUNT;
} else if (this.breakpoint && this.breakpoint.triggeredBy) {
this.context = Context.TRIGGER_POINT;
} else {
this.context = Context.CONDITION;
}
} else {
this.context = context;
}
this.toDispose.push(this.debugService.getModel().onDidChangeBreakpoints(e => {
if (this.breakpoint && e && e.removed && e.removed.indexOf(this.breakpoint) >= 0) {
this.dispose();
}
}));
this.codeEditorService.registerDecorationType('breakpoint-widget', DECORATION_KEY, {});
this.create();
}
private get placeholder(): string {
const acceptString = this.keybindingService.lookupKeybinding(AcceptBreakpointWidgetInputAction.ID)?.getLabel() || 'Enter';
const closeString = this.keybindingService.lookupKeybinding(CloseBreakpointWidgetCommand.ID)?.getLabel() || 'Escape';
switch (this.context) {
case Context.LOG_MESSAGE:
return nls.localize('breakpointWidgetLogMessagePlaceholder', "Message to log when breakpoint is hit. Expressions within {} are interpolated. '{0}' to accept, '{1}' to cancel.", acceptString, closeString);
case Context.HIT_COUNT:
return nls.localize('breakpointWidgetHitCountPlaceholder', "Break when hit count condition is met. '{0}' to accept, '{1}' to cancel.", acceptString, closeString);
default:
return nls.localize('breakpointWidgetExpressionPlaceholder', "Break when expression evaluates to true. '{0}' to accept, '{1}' to cancel.", acceptString, closeString);
}
}
private getInputValue(breakpoint: IBreakpoint | undefined): string {
switch (this.context) {
case Context.LOG_MESSAGE:
return breakpoint && breakpoint.logMessage ? breakpoint.logMessage : this.logMessageInput;
case Context.HIT_COUNT:
return breakpoint && breakpoint.hitCondition ? breakpoint.hitCondition : this.hitCountInput;
default:
return breakpoint && breakpoint.condition ? breakpoint.condition : this.conditionInput;
}
}
private rememberInput(): void {
if (this.context !== Context.TRIGGER_POINT) {
const value = this.input.getModel().getValue();
switch (this.context) {
case Context.LOG_MESSAGE:
this.logMessageInput = value;
break;
case Context.HIT_COUNT:
this.hitCountInput = value;
break;
default:
this.conditionInput = value;
}
}
}
private setInputMode(): void {
if (this.editor.hasModel()) {
// Use plaintext language for log messages, otherwise respect underlying editor language #125619
const languageId = this.context === Context.LOG_MESSAGE ? PLAINTEXT_LANGUAGE_ID : this.editor.getModel().getLanguageId();
this.input.getModel().setLanguage(languageId);
}
}
override show(rangeOrPos: IRange | IPosition): void {
const lineNum = this.input.getModel().getLineCount();
super.show(rangeOrPos, lineNum + 1);
}
fitHeightToContent(): void {
const lineNum = this.input.getModel().getLineCount();
this._relayout(lineNum + 1);
}
protected _fillContainer(container: HTMLElement): void {
this.setCssClass('breakpoint-widget');
const selectBox = new SelectBox(<ISelectOptionItem[]>[
{ text: nls.localize('expression', "Expression") },
{ text: nls.localize('hitCount', "Hit Count") },
{ text: nls.localize('logMessage', "Log Message") },
{ text: nls.localize('triggeredBy', "Wait for Breakpoint") },
], this.context, this.contextViewService, defaultSelectBoxStyles, { ariaLabel: nls.localize('breakpointType', 'Breakpoint Type') });
this.selectContainer = $('.breakpoint-select-container');
selectBox.render(dom.append(container, this.selectContainer));
selectBox.onDidSelect(e => {
this.rememberInput();
this.context = e.index;
this.updateContextInput();
});
this.createModesInput(container);
this.inputContainer = $('.inputContainer');
this.createBreakpointInput(dom.append(container, this.inputContainer));
this.input.getModel().setValue(this.getInputValue(this.breakpoint));
this.toDispose.push(this.input.getModel().onDidChangeContent(() => {
this.fitHeightToContent();
}));
this.input.setPosition({ lineNumber: 1, column: this.input.getModel().getLineMaxColumn(1) });
this.createTriggerBreakpointInput(container);
this.updateContextInput();
// Due to an electron bug we have to do the timeout, otherwise we do not get focus
setTimeout(() => this.focusInput(), 150);
}
private createModesInput(container: HTMLElement) {
const modes = this.debugService.getModel().getBreakpointModes('source');
if (modes.length <= 1) {
return;
}
const sb = this.selectModeBox = new SelectBox(
[
{ text: nls.localize('bpMode', 'Mode'), isDisabled: true },
...modes.map(mode => ({ text: mode.label, description: mode.description })),
],
modes.findIndex(m => m.mode === this.breakpoint?.mode) + 1,
this.contextViewService,
defaultSelectBoxStyles,
);
this.toDispose.push(sb);
this.toDispose.push(sb.onDidSelect(e => {
this.modeInput = modes[e.index - 1];
}));
const modeWrapper = $('.select-mode-container');
const selectionWrapper = $('.select-box-container');
dom.append(modeWrapper, selectionWrapper);
sb.render(selectionWrapper);
dom.append(container, modeWrapper);
}
private createTriggerBreakpointInput(container: HTMLElement) {
const breakpoints = this.debugService.getModel().getBreakpoints().filter(bp => bp !== this.breakpoint && !bp.logMessage);
const breakpointOptions: ISelectOptionItem[] = [
{ text: nls.localize('noTriggerByBreakpoint', 'None'), isDisabled: true },
...breakpoints.map(bp => ({
text: `${this.labelService.getUriLabel(bp.uri, { relative: true })}: ${bp.lineNumber}`,
description: nls.localize('triggerByLoading', 'Loading...')
})),
];
const index = breakpoints.findIndex((bp) => this.breakpoint?.triggeredBy === bp.getId());
for (const [i, bp] of breakpoints.entries()) {
this.textModelService.createModelReference(bp.uri).then(ref => {
try {
breakpointOptions[i + 1].description = ref.object.textEditorModel.getLineContent(bp.lineNumber).trim();
} finally {
ref.dispose();
}
}).catch(() => {
breakpointOptions[i + 1].description = nls.localize('noBpSource', 'Could not load source.');
});
}
const selectBreakpointBox = this.selectBreakpointBox = new SelectBox(breakpointOptions, index + 1, this.contextViewService, defaultSelectBoxStyles, { ariaLabel: nls.localize('selectBreakpoint', 'Select breakpoint') });
selectBreakpointBox.onDidSelect(e => {
if (e.index === 0) {
this.triggeredByBreakpointInput = undefined;
} else {
this.triggeredByBreakpointInput = breakpoints[e.index - 1];
}
});
this.toDispose.push(selectBreakpointBox);
this.selectBreakpointContainer = $('.select-breakpoint-container');
this.toDispose.push(dom.addDisposableListener(this.selectBreakpointContainer, dom.EventType.KEY_DOWN, e => {
const event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.Escape)) {
this.close(false);
}
}));
const selectionWrapper = $('.select-box-container');
dom.append(this.selectBreakpointContainer, selectionWrapper);
selectBreakpointBox.render(selectionWrapper);
dom.append(container, this.selectBreakpointContainer);
const closeButton = new Button(this.selectBreakpointContainer, defaultButtonStyles);
closeButton.label = nls.localize('ok', "Ok");
this.toDispose.push(closeButton.onDidClick(() => this.close(true)));
this.toDispose.push(closeButton);
}
private updateContextInput() {
if (this.context === Context.TRIGGER_POINT) {
this.inputContainer.hidden = true;
this.selectBreakpointContainer.hidden = false;
} else {
this.inputContainer.hidden = false;
this.selectBreakpointContainer.hidden = true;
this.setInputMode();
const value = this.getInputValue(this.breakpoint);
this.input.getModel().setValue(value);
this.focusInput();
}
}
protected override _doLayout(heightInPixel: number, widthInPixel: number): void {
this.heightInPx = heightInPixel;
this.input.layout({ height: heightInPixel, width: widthInPixel - 113 });
this.centerInputVertically();
}
protected override _onWidth(widthInPixel: number): void {
if (typeof this.heightInPx === 'number') {
this._doLayout(this.heightInPx, widthInPixel);
}
}
private createBreakpointInput(container: HTMLElement): void {
const scopedContextKeyService = this.contextKeyService.createScoped(container);
this.toDispose.push(scopedContextKeyService);
const scopedInstatiationService = this.instantiationService.createChild(new ServiceCollection(
[IContextKeyService, scopedContextKeyService],
[IPrivateBreakpointWidgetService, this]
));
this.toDispose.push(scopedInstatiationService);
const options = this.createEditorOptions();
const codeEditorWidgetOptions = getSimpleCodeEditorWidgetOptions();
this.input = <IActiveCodeEditor>scopedInstatiationService.createInstance(CodeEditorWidget, container, options, codeEditorWidgetOptions);
CONTEXT_IN_BREAKPOINT_WIDGET.bindTo(scopedContextKeyService).set(true);
const model = this.modelService.createModel('', null, uri.parse(`${DEBUG_SCHEME}:${this.editor.getId()}:breakpointinput`), true);
if (this.editor.hasModel()) {
model.setLanguage(this.editor.getModel().getLanguageId());
}
this.input.setModel(model);
this.setInputMode();
this.toDispose.push(model);
const setDecorations = () => {
const value = this.input.getModel().getValue();
const decorations = !!value ? [] : createDecorations(this.themeService.getColorTheme(), this.placeholder);
this.input.setDecorationsByType('breakpoint-widget', DECORATION_KEY, decorations);
};
this.input.getModel().onDidChangeContent(() => setDecorations());
this.themeService.onDidColorThemeChange(() => setDecorations());
this.toDispose.push(this.languageFeaturesService.completionProvider.register({ scheme: DEBUG_SCHEME, hasAccessToAllModels: true }, {
_debugDisplayName: 'breakpointWidget',
provideCompletionItems: (model: ITextModel, position: Position, _context: CompletionContext, token: CancellationToken): Promise<CompletionList> => {
let suggestionsPromise: Promise<CompletionList>;
const underlyingModel = this.editor.getModel();
if (underlyingModel && (this.context === Context.CONDITION || (this.context === Context.LOG_MESSAGE && isPositionInCurlyBracketBlock(this.input)))) {
suggestionsPromise = provideSuggestionItems(this.languageFeaturesService.completionProvider, underlyingModel, new Position(this.lineNumber, 1), new CompletionOptions(undefined, new Set<CompletionItemKind>().add(CompletionItemKind.Snippet)), _context, token).then(suggestions => {
let overwriteBefore = 0;
if (this.context === Context.CONDITION) {
overwriteBefore = position.column - 1;
} else {
// Inside the currly brackets, need to count how many useful characters are behind the position so they would all be taken into account
const value = this.input.getModel().getValue();
while ((position.column - 2 - overwriteBefore >= 0) && value[position.column - 2 - overwriteBefore] !== '{' && value[position.column - 2 - overwriteBefore] !== ' ') {
overwriteBefore++;
}
}
return {
suggestions: suggestions.items.map(s => {
s.completion.range = Range.fromPositions(position.delta(0, -overwriteBefore), position);
return s.completion;
})
};
});
} else {
suggestionsPromise = Promise.resolve({ suggestions: [] });
}
return suggestionsPromise;
}
}));
this.toDispose.push(this._configurationService.onDidChangeConfiguration((e) => {
if (e.affectsConfiguration('editor.fontSize') || e.affectsConfiguration('editor.lineHeight')) {
this.input.updateOptions(this.createEditorOptions());
this.centerInputVertically();
}
}));
}
private createEditorOptions(): IEditorOptions {
const editorConfig = this._configurationService.getValue<IEditorOptions>('editor');
const options = getSimpleEditorOptions(this._configurationService);
options.fontSize = editorConfig.fontSize;
options.fontFamily = editorConfig.fontFamily;
options.lineHeight = editorConfig.lineHeight;
options.fontLigatures = editorConfig.fontLigatures;
options.ariaLabel = this.placeholder;
return options;
}
private centerInputVertically() {
if (this.container && typeof this.heightInPx === 'number') {
const lineHeight = this.input.getOption(EditorOption.lineHeight);
const lineNum = this.input.getModel().getLineCount();
const newTopMargin = (this.heightInPx - lineNum * lineHeight) / 2;
this.inputContainer.style.marginTop = newTopMargin + 'px';
}
}
close(success: boolean): void {
if (success) {
// if there is already a breakpoint on this location - remove it.
let condition: string | undefined = undefined;
let hitCondition: string | undefined = undefined;
let logMessage: string | undefined = undefined;
let triggeredBy: string | undefined = undefined;
let mode: string | undefined = undefined;
let modeLabel: string | undefined = undefined;
this.rememberInput();
if (this.conditionInput || this.context === Context.CONDITION) {
condition = this.conditionInput;
}
if (this.hitCountInput || this.context === Context.HIT_COUNT) {
hitCondition = this.hitCountInput;
}
if (this.logMessageInput || this.context === Context.LOG_MESSAGE) {
logMessage = this.logMessageInput;
}
if (this.selectModeBox) {
mode = this.modeInput?.mode;
modeLabel = this.modeInput?.label;
}
if (this.context === Context.TRIGGER_POINT) {
// currently, trigger points don't support additional conditions:
condition = undefined;
hitCondition = undefined;
logMessage = undefined;
triggeredBy = this.triggeredByBreakpointInput?.getId();
}
if (this.breakpoint) {
const data = new Map<string, IBreakpointUpdateData>();
data.set(this.breakpoint.getId(), {
condition,
hitCondition,
logMessage,
triggeredBy,
mode,
modeLabel,
});
this.debugService.updateBreakpoints(this.breakpoint.originalUri, data, false).then(undefined, onUnexpectedError);
} else {
const model = this.editor.getModel();
if (model) {
this.debugService.addBreakpoints(model.uri, [{
lineNumber: this.lineNumber,
column: this.column,
enabled: true,
condition,
hitCondition,
logMessage,
triggeredBy,
mode,
modeLabel,
}]);
}
}
}
this.dispose();
}
private focusInput() {
if (this.context === Context.TRIGGER_POINT) {
this.selectBreakpointBox.focus();
} else {
this.input.focus();
}
}
override dispose(): void {
super.dispose();
this.input.dispose();
lifecycle.dispose(this.toDispose);
setTimeout(() => this.editor.focus(), 0);
}
}
class AcceptBreakpointWidgetInputAction extends EditorCommand {
static ID = 'breakpointWidget.action.acceptInput';
constructor() {
super({
id: AcceptBreakpointWidgetInputAction.ID,
precondition: CONTEXT_BREAKPOINT_WIDGET_VISIBLE,
kbOpts: {
kbExpr: CONTEXT_IN_BREAKPOINT_WIDGET,
primary: KeyCode.Enter,
weight: KeybindingWeight.EditorContrib
}
});
}
runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor): void {
accessor.get(IPrivateBreakpointWidgetService).close(true);
}
}
class CloseBreakpointWidgetCommand extends EditorCommand {
static ID = 'closeBreakpointWidget';
constructor() {
super({
id: CloseBreakpointWidgetCommand.ID,
precondition: CONTEXT_BREAKPOINT_WIDGET_VISIBLE,
kbOpts: {
kbExpr: EditorContextKeys.textInputFocus,
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape],
weight: KeybindingWeight.EditorContrib
}
});
}
runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, args: any): void {
const debugContribution = editor.getContribution<IBreakpointEditorContribution>(BREAKPOINT_EDITOR_CONTRIBUTION_ID);
if (debugContribution) {
// if focus is in outer editor we need to use the debug contribution to close
return debugContribution.closeBreakpointWidget();
}
accessor.get(IPrivateBreakpointWidgetService).close(false);
}
}
registerEditorCommand(new AcceptBreakpointWidgetInputAction());
registerEditorCommand(new CloseBreakpointWidgetCommand());