提交 8031cc50 编写于 作者: D Daniel Imms

Dispose splitview listeners

上级 819c9d13
...@@ -17,6 +17,7 @@ class SplitPaneContainer { ...@@ -17,6 +17,7 @@ class SplitPaneContainer {
private _height: number; private _height: number;
private _width: number; private _width: number;
private _splitView: SplitView; private _splitView: SplitView;
private _splitViewDisposables: IDisposable[];
private _children: SplitPane[] = []; private _children: SplitPane[] = [];
// If the user sizes the panes manually, the proportional resizing will not be applied. // If the user sizes the panes manually, the proportional resizing will not be applied.
...@@ -33,13 +34,19 @@ class SplitPaneContainer { ...@@ -33,13 +34,19 @@ class SplitPaneContainer {
) { ) {
this._width = this._container.offsetWidth; this._width = this._container.offsetWidth;
this._height = this._container.offsetHeight; this._height = this._container.offsetHeight;
this._splitView = new SplitView(this._container, { orientation: this.orientation }); this._createSplitView();
// TODO: Dispose listeners
this._splitView.onDidSashReset(() => this._resetSize());
this._splitView.onDidSashChange(() => this._isManuallySized = true);
this._splitView.layout(this.orientation === Orientation.HORIZONTAL ? this._width : this._height); this._splitView.layout(this.orientation === Orientation.HORIZONTAL ? this._width : this._height);
} }
private _createSplitView(): void {
this._splitView = new SplitView(this._container, { orientation: this.orientation });
this._splitViewDisposables = [];
this._splitViewDisposables.push(this._splitView.onDidSashReset(() => this._resetSize()));
this._splitViewDisposables.push(this._splitView.onDidSashChange(() => {
this._isManuallySized = true;
}));
}
public split(instance: ITerminalInstance, index: number = this._children.length): void { public split(instance: ITerminalInstance, index: number = this._children.length): void {
const size = this.orientation === Orientation.HORIZONTAL ? this._width : this._height; const size = this.orientation === Orientation.HORIZONTAL ? this._width : this._height;
this._addChild(size / (this._children.length + 1), instance, index); this._addChild(size / (this._children.length + 1), instance, index);
...@@ -157,11 +164,12 @@ class SplitPaneContainer { ...@@ -157,11 +164,12 @@ class SplitPaneContainer {
while (this._container.children.length > 0) { while (this._container.children.length > 0) {
this._container.removeChild(this._container.children[0]); this._container.removeChild(this._container.children[0]);
} }
this._splitViewDisposables.forEach(d => d.dispose());
this._splitViewDisposables = [];
this._splitView.dispose(); this._splitView.dispose();
// Create new split view with updated orientation // Create new split view with updated orientation
this._splitView = new SplitView(this._container, { orientation }); this._createSplitView();
this._splitView.onDidSashReset(() => this._resetSize());
this._children.forEach(child => { this._children.forEach(child => {
child.orientation = orientation; child.orientation = orientation;
this._splitView.addView(child, 1); this._splitView.addView(child, 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册