diff --git a/src/vs/editor/browser/widget/diffEditor/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditor/diffEditorWidget.ts index a655b5c8612..c3c798529ca 100644 --- a/src/vs/editor/browser/widget/diffEditor/diffEditorWidget.ts +++ b/src/vs/editor/browser/widget/diffEditor/diffEditorWidget.ts @@ -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); diff --git a/src/vs/editor/browser/widget/diffEditor/utils.ts b/src/vs/editor/browser/widget/diffEditor/utils.ts index 3b968353291..76c37c4185d 100644 --- a/src/vs/editor/browser/widget/diffEditor/utils.ts +++ b/src/vs/editor/browser/widget/diffEditor/utils.ts @@ -96,6 +96,9 @@ export class ObservableElementSizeObserver extends Disposable { private readonly _height: ISettableObservable; public get height(): IObservable { 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 {