close
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions src/vs/workbench/contrib/debug/browser/breakpointWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
import { getSimpleEditorOptions, getSimpleCodeEditorWidgetOptions } from 'vs/workbench/contrib/codeEditor/browser/simpleEditorOptions';
import { IRange, Range } from 'vs/editor/common/core/range';
import { onUnexpectedError } from 'vs/base/common/errors';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions';

const $ = dom.$;
const IPrivateBreakpointWidgetService = createDecorator<IPrivateBreakpointWidgetService>('privateBreakpointWidgetService');
Expand All @@ -48,13 +50,15 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
_serviceBrand: undefined;

private selectContainer!: HTMLElement;
private inputContainer!: HTMLElement;
private input!: IActiveCodeEditor;
private toDispose: lifecycle.IDisposable[];
private conditionInput = '';
private hitCountInput = '';
private logMessageInput = '';
private breakpoint: IBreakpoint | undefined;
private context: Context;
private heightInPx: number;

constructor(editor: ICodeEditor, private lineNumber: number, private column: number | undefined, context: Context | undefined,
@IContextViewService private readonly contextViewService: IContextViewService,
Expand All @@ -64,6 +68,7 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IModelService private readonly modelService: IModelService,
@ICodeEditorService private readonly codeEditorService: ICodeEditorService,
@IConfigurationService private readonly _configurationService: IConfigurationService
) {
super(editor, { showFrame: true, showArrow: false, frameWidth: 1 });

Expand Down Expand Up @@ -158,7 +163,8 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
this.input.focus();
});

this.createBreakpointInput(dom.append(container, $('.inputContainer')));
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(() => {
Expand All @@ -170,7 +176,9 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
}

protected _doLayout(heightInPixel: number, widthInPixel: number): void {
this.heightInPx = heightInPixel;
this.input.layout({ height: heightInPixel, width: widthInPixel - 113 });
this.centerInputVertically();
}

private createBreakpointInput(container: HTMLElement): void {
Expand All @@ -180,7 +188,7 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
const scopedInstatiationService = this.instantiationService.createChild(new ServiceCollection(
[IContextKeyService, scopedContextKeyService], [IPrivateBreakpointWidgetService, this]));

const options = getSimpleEditorOptions();
const options = this.createEditorOptions();
const codeEditorWidgetOptions = getSimpleCodeEditorWidgetOptions();
this.input = <IActiveCodeEditor>scopedInstatiationService.createInstance(CodeEditorWidget, container, options, codeEditorWidgetOptions);
CONTEXT_IN_BREAKPOINT_WIDGET.bindTo(scopedContextKeyService).set(true);
Expand Down Expand Up @@ -227,6 +235,29 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
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();
options.fontSize = editorConfig.fontSize;
return options;
}

private centerInputVertically() {
if (this.container) {
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';
Comment thread
anirudhrb marked this conversation as resolved.
}
}

private createDecorations(): IDecorationOptions[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@

.monaco-editor .zone-widget .zone-widget-container.breakpoint-widget .inputContainer {
flex: 1;
margin-top: 8px;
}