Skip to content

Commit f7349ba

Browse files
committed
Fix logic for 1 editor Inc/Dec View command
1 parent 8dfa696 commit f7349ba

1 file changed

Lines changed: 25 additions & 9 deletions

File tree

src/vs/workbench/browser/layout.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,10 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
700700

701701
// change part size along the main axis
702702
public resizePart(part: Parts, sizeChange: number): void {
703-
const visibleEditors = this.editorService.getVisibleEditors().length;
703+
const visibleEditorCount = this.editorService.getVisibleEditors().length;
704+
const isSidebarVisible = this.partService.isVisible(Parts.SIDEBAR_PART);
705+
const isPanelVisible = this.partService.isVisible(Parts.PANEL_PART);
706+
const panelPosition = this.partService.getPanelPosition();
704707
const sizeChangePxWidth = this.workbenchSize.width * (sizeChange / 100);
705708
const sizeChangePxHeight = this.workbenchSize.height * (sizeChange / 100);
706709

@@ -710,24 +713,37 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
710713
case Parts.SIDEBAR_PART:
711714
this.sidebarWidth = this.sidebarWidth + sizeChangePxWidth; // Sidebar can not become smaller than MIN_PART_WIDTH
712715

713-
if (this.layoutEditorGroupsVertically && (this.workbenchSize.width - this.sidebarWidth < visibleEditors * MIN_EDITOR_PART_WIDTH)) {
714-
this.sidebarWidth = (this.workbenchSize.width - visibleEditors * MIN_EDITOR_PART_WIDTH);
716+
if (this.layoutEditorGroupsVertically && (this.workbenchSize.width - this.sidebarWidth < visibleEditorCount * MIN_EDITOR_PART_WIDTH)) {
717+
this.sidebarWidth = (this.workbenchSize.width - visibleEditorCount * MIN_EDITOR_PART_WIDTH);
715718
}
716719

717720
doLayout = true;
718721
break;
719722
case Parts.PANEL_PART:
720-
this.panelHeight = this.panelHeight + sizeChangePxHeight;
721-
this.panelWidth = this.panelWidth + sizeChangePxWidth;
723+
if (panelPosition === Position.BOTTOM) {
724+
this.panelHeight = this.panelHeight + sizeChangePxHeight;
725+
} else if (panelPosition === Position.RIGHT) {
726+
this.panelWidth = this.panelWidth + sizeChangePxWidth;
727+
}
728+
722729
doLayout = true;
723730
break;
724731
case Parts.EDITOR_PART:
725732
// If we have one editor we can cheat and resize sidebar with the negative delta
726-
const visibleEditorCount = this.editorService.getVisibleEditors().length;
727-
733+
// If the sidebar is not visible and panel is, resize panel main axis with negative Delta
728734
if (visibleEditorCount === 1) {
729-
this.sidebarWidth = this.sidebarWidth - sizeChangePxWidth;
730-
doLayout = true;
735+
if (isSidebarVisible) {
736+
this.sidebarWidth = this.sidebarWidth - sizeChangePxWidth;
737+
doLayout = true;
738+
} else if (isPanelVisible) {
739+
if (panelPosition === Position.BOTTOM) {
740+
this.panelHeight = this.panelHeight - sizeChangePxHeight;
741+
} else if (panelPosition === Position.RIGHT) {
742+
this.panelWidth = this.panelWidth - sizeChangePxWidth;
743+
}
744+
doLayout = true;
745+
}
746+
731747
} else {
732748
const stacks = this.editorGroupService.getStacksModel();
733749
const activeGroup = stacks.positionOfGroup(stacks.activeGroup);

0 commit comments

Comments
 (0)