提交 7324bc17 编写于 作者: S SteVen Batten

prevent editor taking up more than its share

fixes #79897
上级 f03f5fde
......@@ -608,6 +608,23 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
return offset;
}
getMaximumEditorDimensions(): Dimension {
const takenWidth =
(this.isVisible(Parts.ACTIVITYBAR_PART) ? this.activityBarPartView.minimumWidth : 0) +
(this.isVisible(Parts.SIDEBAR_PART) ? this.sideBarPartView.minimumWidth : 0) +
(this.isVisible(Parts.PANEL_PART) && this.state.panel.position === Position.RIGHT ? this.panelPartView.minimumWidth : 0);
const takenHeight =
(this.isVisible(Parts.TITLEBAR_PART) ? this.titleBarPartView.minimumHeight : 0) +
(this.isVisible(Parts.STATUSBAR_PART) ? this.statusBarPartView.minimumHeight : 0) +
(this.isVisible(Parts.PANEL_PART) && this.state.panel.position === Position.BOTTOM ? this.panelPartView.minimumHeight : 0);
const availableWidth = this.dimension.width - takenWidth;
const availableHeight = this.dimension.height - takenHeight;
return { width: availableWidth, height: availableHeight };
}
getWorkbenchContainer(): HTMLElement {
return this.parent;
}
......
......@@ -140,7 +140,7 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
@IThemeService themeService: IThemeService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IStorageService storageService: IStorageService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService
) {
super(Parts.EDITOR_PART, { hasTitle: false }, themeService, storageService, layoutService);
......@@ -780,9 +780,10 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
//#region Part
get minimumWidth(): number { return this.centeredLayoutWidget.minimumWidth; }
// TODO @sbatten @joao find something better to prevent editor taking over #79897
get minimumWidth(): number { return Math.min(this.centeredLayoutWidget.minimumWidth, this.layoutService.getMaximumEditorDimensions().width); }
get maximumWidth(): number { return this.centeredLayoutWidget.maximumWidth; }
get minimumHeight(): number { return this.centeredLayoutWidget.minimumHeight; }
get minimumHeight(): number { return Math.min(this.centeredLayoutWidget.minimumHeight, this.layoutService.getMaximumEditorDimensions().height); }
get maximumHeight(): number { return this.centeredLayoutWidget.maximumHeight; }
readonly snap = true;
......
......@@ -144,6 +144,11 @@ export interface IWorkbenchLayoutService extends ILayoutService {
*/
setPanelPosition(position: Position): void;
/**
* Gets the maximum possible size for editor.
*/
getMaximumEditorDimensions(): Dimension;
/**
* Returns the element that is parent of the workbench element.
*/
......
......@@ -541,6 +541,8 @@ export class TestLayoutService implements IWorkbenchLayoutService {
public addClass(_clazz: string): void { }
public removeClass(_clazz: string): void { }
public getMaximumEditorDimensions(): Dimension { throw new Error('not implemented'); }
public getWorkbenchContainer(): HTMLElement { throw new Error('not implemented'); }
public getWorkbenchElement(): HTMLElement { throw new Error('not implemented'); }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册