4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
6
import { Event } from 'vs/base/common/event' ;
7
+ import { IReference } from 'vs/base/common/lifecycle' ;
7
8
import * as paths from 'vs/base/common/path' ;
8
9
import { isEqual } from 'vs/base/common/resources' ;
9
10
import { URI } from 'vs/base/common/uri' ;
10
- import { ITextModel } from 'vs/editor/common/model' ;
11
11
import { IModelService } from 'vs/editor/common/services/modelService' ;
12
+ import { IResolvedTextEditorModel , ITextModelService } from 'vs/editor/common/services/resolverService' ;
12
13
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
13
14
import { IUntypedEditorInput } from 'vs/workbench/common/editor' ;
14
15
import { EditorInput } from 'vs/workbench/common/editor/editorInput' ;
@@ -54,16 +55,12 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
54
55
private _inputResolver : Promise < IResolvedNotebookEditorModel | null > | null ;
55
56
private _editorModelReference : IResolvedNotebookEditorModel | null ;
56
57
57
- private _inputModel : ITextModel | null ;
58
-
59
- get inputModel ( ) {
60
- return this . _inputModel ;
61
- }
58
+ private _inputModelRef : IReference < IResolvedTextEditorModel > | null ;
62
59
63
60
get primary ( ) : EditorInput {
64
61
return this . _notebookEditorInput ;
65
62
}
66
- private _modelService : IModelService ;
63
+ private _textModelService : ITextModelService ;
67
64
private _interactiveDocumentService : IInteractiveDocumentService ;
68
65
69
66
@@ -73,6 +70,8 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
73
70
title : string | undefined ,
74
71
@IInstantiationService instantiationService : IInstantiationService ,
75
72
@IModelService modelService : IModelService ,
73
+ @ITextModelService textModelService : ITextModelService ,
74
+
76
75
@IInteractiveDocumentService interactiveDocumentService : IInteractiveDocumentService
77
76
) {
78
77
const input = NotebookEditorInput . create ( instantiationService , resource , 'interactive' , { } ) ;
@@ -83,8 +82,8 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
83
82
this . _inputResource = inputResource ;
84
83
this . _inputResolver = null ;
85
84
this . _editorModelReference = null ;
86
- this . _inputModel = null ;
87
- this . _modelService = modelService ;
85
+ this . _inputModelRef = null ;
86
+ this . _textModelService = textModelService ;
88
87
this . _interactiveDocumentService = interactiveDocumentService ;
89
88
90
89
this . _registerListeners ( ) ;
@@ -131,14 +130,15 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
131
130
return this . _inputResolver ;
132
131
}
133
132
134
- resolveInput ( language : string ) {
135
- if ( this . _inputModel ) {
136
- return this . _inputModel ;
133
+ async resolveInput ( language : string ) {
134
+ if ( this . _inputModelRef ) {
135
+ return this . _inputModelRef . object . textEditorModel ;
137
136
}
138
137
139
138
this . _interactiveDocumentService . willCreateInteractiveDocument ( this . resource ! , this . inputResource , language ) ;
140
- this . _inputModel = this . _modelService . createModel ( '' , null , this . inputResource , false ) ;
141
- return this . _inputModel ;
139
+ this . _inputModelRef = await this . _textModelService . createModelReference ( this . inputResource ) ;
140
+
141
+ return this . _inputModelRef . object . textEditorModel ;
142
142
}
143
143
144
144
override matches ( otherInput : EditorInput | IUntypedEditorInput ) : boolean {
@@ -170,8 +170,8 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
170
170
this . _editorModelReference ?. dispose ( ) ;
171
171
this . _editorModelReference = null ;
172
172
this . _interactiveDocumentService . willRemoveInteractiveDocument ( this . resource ! , this . inputResource ) ;
173
- this . _inputModel ?. dispose ( ) ;
174
- this . _inputModel = null ;
173
+ this . _inputModelRef ?. dispose ( ) ;
174
+ this . _inputModelRef = null ;
175
175
super . dispose ( ) ;
176
176
}
177
177
}
0 commit comments