Merge pull request #17760 from charlespierce/preserve_layout

#14464 Preserve editor size when switching layout
This commit is contained in:
Benjamin Pasero 2017-01-05 16:07:38 +01:00 committed by GitHub
commit c43059c041

View file

@ -758,7 +758,7 @@ export class EditorGroupsControl implements IEditorGroupsControl, IVerticalSashL
this.sashTwo.setOrientation(this.layoutVertically ? Orientation.VERTICAL : Orientation.HORIZONTAL);
// Trigger layout
this.arrangeGroups(GroupArrangement.EVEN);
this.arrangeGroups();
}
}
@ -766,7 +766,7 @@ export class EditorGroupsControl implements IEditorGroupsControl, IVerticalSashL
return this.layoutVertically ? 'vertical' : 'horizontal';
}
public arrangeGroups(arrangement: GroupArrangement): void {
public arrangeGroups(arrangement?: GroupArrangement): void {
if (!this.dimension) {
return; // too early
}
@ -778,27 +778,49 @@ export class EditorGroupsControl implements IEditorGroupsControl, IVerticalSashL
return; // need more editors
}
// Minimize Others
if (arrangement === GroupArrangement.MINIMIZE_OTHERS) {
POSITIONS.forEach(position => {
if (this.visibleEditors[position]) {
if (position !== this.lastActivePosition) {
this.silosSize[position] = this.minSize;
availableSize -= this.minSize;
switch (arrangement) {
case GroupArrangement.MINIMIZE_OTHERS:
// Minimize Others
POSITIONS.forEach(position => {
if (this.visibleEditors[position]) {
if (position !== this.lastActivePosition) {
this.silosSize[position] = this.minSize;
availableSize -= this.minSize;
}
}
}
});
});
this.silosSize[this.lastActivePosition] = availableSize;
}
this.silosSize[this.lastActivePosition] = availableSize;
break;
case GroupArrangement.EVEN:
// Even Sizes
POSITIONS.forEach(position => {
if (this.visibleEditors[position]) {
this.silosSize[position] = availableSize / visibleEditors;
}
});
break;
default:
// Minimized editors should remain minimized, others should keep their relative Sizes
let oldNonMinimizedTotal = 0;
POSITIONS.forEach(position => {
if (this.visibleEditors[position]) {
if (this.silosMinimized[position]) {
this.silosSize[position] = this.minSize;
availableSize -= this.minSize;
} else {
oldNonMinimizedTotal += this.silosSize[position];
}
}
});
// Even Sizes
else if (arrangement === GroupArrangement.EVEN) {
POSITIONS.forEach(position => {
if (this.visibleEditors[position]) {
this.silosSize[position] = availableSize / visibleEditors;
}
});
// Set size for non-minimized editors
const scaleFactor = availableSize / oldNonMinimizedTotal;
POSITIONS.forEach(position => {
if (this.visibleEditors[position] && !this.silosMinimized[position]) {
this.silosSize[position] *= scaleFactor;
}
});
}
// Since we triggered a change in minimized/maximized editors, we need