Skip to content

Commit

Permalink
Merge pull request microsoft#37348 from cleidigh/inc-dec-view-single-…
Browse files Browse the repository at this point in the history
…editor/bug

Fix logic for 1 editor Inc/Dec View command Fixes: microsoft#37347
  • Loading branch information
isidorn authored Nov 8, 2017
2 parents 0e240e4 + 00f7474 commit 6b5850e
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/vs/workbench/browser/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,8 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal

// change part size along the main axis
public resizePart(part: Parts, sizeChange: number): void {
const visibleEditors = this.editorService.getVisibleEditors().length;
const visibleEditorCount = this.editorService.getVisibleEditors().length;
const panelPosition = this.partService.getPanelPosition();
const sizeChangePxWidth = this.workbenchSize.width * (sizeChange / 100);
const sizeChangePxHeight = this.workbenchSize.height * (sizeChange / 100);

Expand All @@ -720,24 +721,37 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
case Parts.SIDEBAR_PART:
this.sidebarWidth = this.sidebarWidth + sizeChangePxWidth; // Sidebar can not become smaller than MIN_PART_WIDTH

if (this.layoutEditorGroupsVertically && (this.workbenchSize.width - this.sidebarWidth < visibleEditors * MIN_EDITOR_PART_WIDTH)) {
this.sidebarWidth = (this.workbenchSize.width - visibleEditors * MIN_EDITOR_PART_WIDTH);
if (this.layoutEditorGroupsVertically && (this.workbenchSize.width - this.sidebarWidth < visibleEditorCount * MIN_EDITOR_PART_WIDTH)) {
this.sidebarWidth = (this.workbenchSize.width - visibleEditorCount * MIN_EDITOR_PART_WIDTH);
}

doLayout = true;
break;
case Parts.PANEL_PART:
this.panelHeight = this.panelHeight + sizeChangePxHeight;
this.panelWidth = this.panelWidth + sizeChangePxWidth;
if (panelPosition === Position.BOTTOM) {
this.panelHeight = this.panelHeight + sizeChangePxHeight;
} else if (panelPosition === Position.RIGHT) {
this.panelWidth = this.panelWidth + sizeChangePxWidth;
}

doLayout = true;
break;
case Parts.EDITOR_PART:
// If we have one editor we can cheat and resize sidebar with the negative delta
const visibleEditorCount = this.editorService.getVisibleEditors().length;

// If the sidebar is not visible and panel is, resize panel main axis with negative Delta
if (visibleEditorCount === 1) {
this.sidebarWidth = this.sidebarWidth - sizeChangePxWidth;
doLayout = true;
if (this.partService.isVisible(Parts.SIDEBAR_PART)) {
this.sidebarWidth = this.sidebarWidth - sizeChangePxWidth;
doLayout = true;
} else if (this.partService.isVisible(Parts.PANEL_PART)) {
if (panelPosition === Position.BOTTOM) {
this.panelHeight = this.panelHeight - sizeChangePxHeight;
} else if (panelPosition === Position.RIGHT) {
this.panelWidth = this.panelWidth - sizeChangePxWidth;
}
doLayout = true;
}

} else {
const stacks = this.editorGroupService.getStacksModel();
const activeGroup = stacks.positionOfGroup(stacks.activeGroup);
Expand Down

0 comments on commit 6b5850e

Please sign in to comment.