Fixes diff editor height in monaco editor playground example. (#213585)

This commit is contained in:
Henning Dieterichs 2024-05-27 19:14:54 +02:00 committed by GitHub
parent 4e111f4ad1
commit e9a1af2326
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View file

@ -56,7 +56,7 @@ export interface IDiffCodeEditorWidgetOptions {
export class DiffEditorWidget extends DelegatingEditor implements IDiffEditor {
public static ENTIRE_DIFF_OVERVIEW_WIDTH = OverviewRulerFeature.ENTIRE_DIFF_OVERVIEW_WIDTH;
private readonly elements = h('div.monaco-diff-editor.side-by-side', { style: { position: 'relative' } }, [
private readonly elements = h('div.monaco-diff-editor.side-by-side', { style: { position: 'relative', height: '100%' } }, [
h('div.editor.original@original', { style: { position: 'absolute', height: '100%', } }),
h('div.editor.modified@modified', { style: { position: 'absolute', height: '100%', } }),
h('div.accessibleDiffViewer@accessibleDiffViewer', { style: { position: 'absolute', height: '100%' } }),
@ -344,7 +344,12 @@ export class DiffEditorWidget extends DelegatingEditor implements IDiffEditor {
private readonly _layoutInfo = derived(this, reader => {
const fullWidth = this._rootSizeObserver.width.read(reader);
const fullHeight = this._rootSizeObserver.height.read(reader);
this.elements.root.style.height = fullHeight + 'px';
if (this._rootSizeObserver.automaticLayout) {
this.elements.root.style.height = '100%';
} else {
this.elements.root.style.height = fullHeight + 'px';
}
const sash = this._sash.read(reader);

View file

@ -96,6 +96,9 @@ export class ObservableElementSizeObserver extends Disposable {
private readonly _height: ISettableObservable<number>;
public get height(): IObservable<number> { return this._height; }
private _automaticLayout: boolean = false;
public get automaticLayout(): boolean { return this._automaticLayout; }
constructor(element: HTMLElement | null, dimension: IDimension | undefined) {
super();
@ -115,6 +118,7 @@ export class ObservableElementSizeObserver extends Disposable {
}
public setAutomaticLayout(automaticLayout: boolean): void {
this._automaticLayout = automaticLayout;
if (automaticLayout) {
this.elementSizeObserver.startObserving();
} else {