11import { Emitter , IDisposable , IEventBus , MaybeNull } from '@opensumi/ide-core-browser' ;
2- import { makeRandomHexString } from '@opensumi/ide-core-common' ;
2+ import { DisposableStore , makeRandomHexString } from '@opensumi/ide-core-common' ;
33
44import { Direction , IEditorGroup , IEditorGroupState } from '../../common' ;
55import { GridResizeEvent } from '../types' ;
66
77export const editorGridUid = new Set ( ) ;
88
99export class EditorGrid implements IDisposable {
10+ private _disposables = new DisposableStore ( ) ;
11+
1012 public editorGroup : IGridEditorGroup | null = null ;
1113
1214 public children : EditorGrid [ ] = [ ] ;
1315
1416 public splitDirection : SplitDirection | undefined ;
1517
16- protected readonly _onDidGridStateChange = new Emitter < void > ( ) ;
18+ protected readonly _onDidGridStateChange = this . _disposables . add ( new Emitter < void > ( ) ) ;
1719
1820 public readonly onDidGridStateChange = this . _onDidGridStateChange . event ;
1921
20- protected readonly _onDidGridAndDesendantStateChange = new Emitter < void > ( ) ;
22+ protected readonly _onDidGridAndDesendantStateChange = this . _disposables . add ( new Emitter < void > ( ) ) ;
2123
2224 public readonly onDidGridAndDesendantStateChange = this . _onDidGridAndDesendantStateChange . event ;
2325
@@ -30,10 +32,12 @@ export class EditorGrid implements IDisposable {
3032 }
3133 this . uid = uid ;
3234 editorGridUid . add ( uid ) ;
33- this . onDidGridStateChange ( ( ) => {
34- this . _onDidGridAndDesendantStateChange . fire ( ) ;
35- this . parent ?. _onDidGridAndDesendantStateChange . fire ( ) ;
36- } ) ;
35+ this . _disposables . add (
36+ this . onDidGridStateChange ( ( ) => {
37+ this . _onDidGridAndDesendantStateChange . fire ( ) ;
38+ this . parent ?. _onDidGridAndDesendantStateChange . fire ( ) ;
39+ } ) ,
40+ ) ;
3741 }
3842
3943 setEditorGroup ( editorGroup : IGridEditorGroup ) {
@@ -106,6 +110,8 @@ export class EditorGrid implements IDisposable {
106110 } else {
107111 // 应该不会落入这里
108112 }
113+
114+ this . _disposables . dispose ( ) ;
109115 }
110116
111117 public replaceBy ( target : EditorGrid ) {
0 commit comments