提交 c43059c0 编写于 作者: B Benjamin Pasero 提交者: GitHub

Merge pull request #17760 from charlespierce/preserve_layout

#14464 Preserve editor size when switching layout
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册