提交 68054914 编写于 作者: D Daniel Imms

Evenly spread out term panes on sash reset

上级 696d9909
......@@ -91,6 +91,8 @@ export class SplitView implements IDisposable {
private _onDidSashChange = new Emitter<void>();
readonly onDidSashChange = this._onDidSashChange.event;
private _onDidSashReset = new Emitter<void>();
readonly onDidSashReset = this._onDidSashReset.event;
get length(): number {
return this.viewItems.length;
......@@ -153,8 +155,10 @@ export class SplitView implements IDisposable {
const onSashChangeDisposable = onChange(this.onSashChange, this);
const onEnd = mapEvent<void, void>(sash.onDidEnd, () => null);
const onEndDisposable = onEnd(() => this._onDidSashChange.fire());
const onDidReset = mapEvent<void, void>(sash.onDidReset, () => null);
const onDidResetDisposable = onDidReset(() => this._onDidSashReset.fire());
const disposable = combinedDisposable([onStartDisposable, onSashChangeDisposable, onEndDisposable, sash]);
const disposable = combinedDisposable([onStartDisposable, onSashChangeDisposable, onEndDisposable, onDidResetDisposable, sash]);
const sashItem: ISashItem = { sash, disposable };
this.sashItems.splice(index - 1, 0, sashItem);
......
......@@ -42,6 +42,7 @@ class SplitPane implements IView {
container.removeChild((<any>this.instance)._wrapperElement);
this._splitView = new SplitView(container, { orientation });
this._splitView.onDidSashReset(() => this._resetSize());
this.layout(this._size);
this.orthogonalLayout(this.orthogonalSize);
......@@ -78,6 +79,17 @@ class SplitPane implements IView {
this._onDidChange = anyEvent(...this._children.map(c => c.onDidChange));
}
private _resetSize(): void {
let totalSize = 0;
for (let i = 0; i < this._splitView.length; i++) {
totalSize += this._splitView.getViewSize(i);
}
const newSize = Math.floor(totalSize / this._splitView.length);
for (let i = 0; i < this._splitView.length - 1; i++) {
this._splitView.resizeView(i, newSize);
}
}
public remove(): void {
if (!this._parent) {
return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册