Merge pull request #21296 from michelkaporin/exception-widget

Exception widget resizing
This commit is contained in:
Isidor Nikolic 2017-02-23 19:48:57 +01:00 committed by GitHub
commit de731d6b74
2 changed files with 16 additions and 1 deletions

View file

@ -10,6 +10,7 @@ import { ZoneWidget } from 'vs/editor/contrib/zoneWidget/browser/zoneWidget';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IDebugService } from 'vs/workbench/parts/debug/common/debug';
import { RunOnceScheduler } from 'vs/base/common/async';
const $ = dom.$;
export class ExceptionWidget extends ZoneWidget {
@ -21,10 +22,16 @@ export class ExceptionWidget extends ZoneWidget {
super(editor, { showFrame: true, showArrow: true, frameWidth: 1 });
this.create();
const onDidLayoutChangeScheduler = new RunOnceScheduler(() => this._doLayout(undefined, undefined), 50);
this._disposables.add(this.editor.onDidLayoutChange(() => onDidLayoutChangeScheduler.schedule()));
}
protected _fillContainer(container: HTMLElement): void {
this.setCssClass('exception-widget');
// Set the font size and line height to the one from the editor configuration.
const fontInfo = this.editor.getConfiguration().fontInfo;
this.container.style.fontSize = `${fontInfo.fontSize}px`;
this.container.style.lineHeight = `${fontInfo.lineHeight}px`;
let title = $('.title');
title.textContent = nls.localize('exceptionThrown', 'Exception occured');
@ -37,4 +44,12 @@ export class ExceptionWidget extends ZoneWidget {
dom.append(container, msg);
}
}
protected _doLayout(heightInPixel: number, widthInPixel: number): void {
// Reload the height with respect to the exception text content and relayout it to match the line count.
this.container.style.height = 'initial';
const computedLinesNumber = Math.ceil(this.container.offsetHeight / this.editor.getConfiguration().fontInfo.lineHeight);
this._relayout(computedLinesNumber);
}
}

View file

@ -332,7 +332,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
}
this.exceptionWidget = this.instantiationService.createInstance(ExceptionWidget, this.editor, lineNumber);
this.exceptionWidget.show({ lineNumber, column }, 3);
this.exceptionWidget.show({ lineNumber, column }, 0);
}
private closeExceptionWidget(): void {