File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
src/vs/editor/browser/widget Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 5
5
6
6
import { getWindow , runWhenWindowIdle } from 'vs/base/browser/dom' ;
7
7
import { onUnexpectedError } from 'vs/base/common/errors' ;
8
- import { Disposable , DisposableMap } from 'vs/base/common/lifecycle' ;
8
+ import { Disposable , DisposableMap , IDisposable } from 'vs/base/common/lifecycle' ;
9
9
import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
10
10
import { EditorContributionInstantiation , IEditorContributionDescription } from 'vs/editor/browser/editorExtensions' ;
11
11
import { IEditorContribution } from 'vs/editor/common/editorCommon' ;
@@ -111,10 +111,10 @@ export class CodeEditorContributions extends Disposable {
111
111
this . _instantiateSome ( EditorContributionInstantiation . BeforeFirstInteraction ) ;
112
112
}
113
113
114
- public onAfterModelAttached ( ) : void {
115
- this . _register ( runWhenWindowIdle ( getWindow ( this . _editor ?. getDomNode ( ) ) , ( ) => {
114
+ public onAfterModelAttached ( ) : IDisposable {
115
+ return runWhenWindowIdle ( getWindow ( this . _editor ?. getDomNode ( ) ) , ( ) => {
116
116
this . _instantiateSome ( EditorContributionInstantiation . AfterFirstRender ) ;
117
- } , 50 ) ) ;
117
+ } , 50 ) ;
118
118
}
119
119
120
120
private _instantiateSome ( instantiation : EditorContributionInstantiation ) : void {
Original file line number Diff line number Diff line change @@ -242,6 +242,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
242
242
private readonly _overflowWidgetsDomNode : HTMLElement | undefined ;
243
243
private readonly _id : number ;
244
244
private readonly _configuration : IEditorConfiguration ;
245
+ private _contributionsDisposable : IDisposable | undefined ;
245
246
246
247
protected readonly _actions = new Map < string , editorCommon . IEditorAction > ( ) ;
247
248
@@ -523,7 +524,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
523
524
this . _onDidChangeModel . fire ( e ) ;
524
525
this . _postDetachModelCleanup ( detachedModel ) ;
525
526
526
- this . _contributions . onAfterModelAttached ( ) ;
527
+ this . _contributionsDisposable = this . _contributions . onAfterModelAttached ( ) ;
527
528
}
528
529
529
530
private _removeDecorationTypes ( ) : void {
@@ -1871,6 +1872,8 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
1871
1872
}
1872
1873
1873
1874
private _detachModel ( ) : ITextModel | null {
1875
+ this . _contributionsDisposable ?. dispose ( ) ;
1876
+ this . _contributionsDisposable = undefined ;
1874
1877
if ( ! this . _modelData ) {
1875
1878
return null ;
1876
1879
}
@@ -1887,7 +1890,6 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
1887
1890
if ( this . _bannerDomNode && this . _domElement . contains ( this . _bannerDomNode ) ) {
1888
1891
this . _domElement . removeChild ( this . _bannerDomNode ) ;
1889
1892
}
1890
-
1891
1893
return model ;
1892
1894
}
1893
1895
You can’t perform that action at this time.
0 commit comments