3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
- import { VSBuffer } from 'vs/base/common/buffer' ;
7
6
import { Event } from 'vs/base/common/event' ;
8
7
import { IReference } from 'vs/base/common/lifecycle' ;
9
8
import * as paths from 'vs/base/common/path' ;
@@ -16,9 +15,7 @@ import { EditorInputCapabilities, GroupIdentifier, ISaveOptions, IUntypedEditorI
16
15
import { EditorInput } from 'vs/workbench/common/editor/editorInput' ;
17
16
import { IInteractiveDocumentService } from 'vs/workbench/contrib/interactive/browser/interactiveDocumentService' ;
18
17
import { IInteractiveHistoryService } from 'vs/workbench/contrib/interactive/browser/interactiveHistoryService' ;
19
- import { NotebookCellTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookCellTextModel' ;
20
- import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel' ;
21
- import { CellKind , ICellDto2 , IOutputDto , IResolvedNotebookEditorModel , NotebookCellCollapseState , NotebookCellInternalMetadata , NotebookCellMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
18
+ import { IResolvedNotebookEditorModel } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
22
19
import { ICompositeNotebookEditorInput , NotebookEditorInput } from 'vs/workbench/contrib/notebook/common/notebookEditorInput' ;
23
20
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService' ;
24
21
@@ -139,13 +136,7 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
139
136
return this . _inputResolver ;
140
137
}
141
138
142
- this . _inputResolver = this . _resolveEditorModel ( ) . then ( editorModel => {
143
- if ( this . _data ) {
144
- editorModel ?. notebook . reset ( this . _data . notebookData . cells . map ( ( cell : ISerializedCell ) => deserializeCell ( cell ) ) , this . _data . notebookData . metadata , this . _data . notebookData . transientOptions ) ;
145
- }
146
-
147
- return editorModel ;
148
- } ) ;
139
+ this . _inputResolver = this . _resolveEditorModel ( ) ;
149
140
150
141
return this . _inputResolver ;
151
142
}
@@ -158,10 +149,6 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
158
149
this . _interactiveDocumentService . willCreateInteractiveDocument ( this . resource ! , this . inputResource , language ) ;
159
150
this . _inputModelRef = await this . _textModelService . createModelReference ( this . inputResource ) ;
160
151
161
- if ( this . _data && this . _data . inputData ) {
162
- this . _inputModelRef . object . textEditorModel . setValue ( this . _data . inputData . value ) ;
163
- }
164
-
165
152
return this . _inputModelRef . object . textEditorModel ;
166
153
}
167
154
@@ -222,37 +209,6 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
222
209
return basename . substr ( 0 , basename . length - paths . extname ( p ) . length ) ;
223
210
}
224
211
225
- getSerialization ( ) : { notebookData : any | undefined ; inputData : any | undefined } {
226
- return {
227
- notebookData : this . _serializeNotebook ( this . _editorModelReference ?. notebook ) ,
228
- inputData : this . _inputModelRef ? {
229
- value : this . _inputModelRef . object . textEditorModel . getValue ( ) ,
230
- language : this . _inputModelRef . object . textEditorModel . getLanguageId ( )
231
- } : undefined
232
- } ;
233
- }
234
-
235
- private _data : { notebookData : any | undefined ; inputData : any | undefined } | undefined ;
236
-
237
- async restoreSerialization ( data : { notebookData : any | undefined ; inputData : any | undefined } | undefined ) {
238
- this . _data = data ;
239
- }
240
-
241
- private _serializeNotebook ( notebook ?: NotebookTextModel ) {
242
- if ( ! notebook ) {
243
- return undefined ;
244
- }
245
-
246
- const cells = notebook . cells . map ( cell => serializeCell ( cell ) ) ;
247
-
248
- return {
249
- cells : cells ,
250
- metadata : notebook . metadata ,
251
- transientOptions : notebook . transientOptions
252
- } ;
253
- }
254
-
255
-
256
212
override dispose ( ) {
257
213
// we support closing the interactive window without prompt, so the editor model should not be dirty
258
214
this . _editorModelReference ?. revert ( { soft : true } ) ;
@@ -270,74 +226,3 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
270
226
return this . _historyService ;
271
227
}
272
228
}
273
-
274
- /**
275
- * Serialization of interactive notebook.
276
- * This is not placed in notebook land as regular notebooks are handled by file service directly.
277
- */
278
-
279
- interface ISerializedOutputItem {
280
- readonly mime : string ;
281
- readonly data : number [ ] ;
282
- }
283
-
284
- interface ISerializedCellOutput {
285
- outputs : ISerializedOutputItem [ ] ;
286
- metadata ?: Record < string , any > ;
287
- outputId : string ;
288
- }
289
-
290
- export interface ISerializedCell {
291
- source : string ;
292
- language : string ;
293
- mime : string | undefined ;
294
- cellKind : CellKind ;
295
- outputs : ISerializedCellOutput [ ] ;
296
- metadata ?: NotebookCellMetadata ;
297
- internalMetadata ?: NotebookCellInternalMetadata ;
298
- collapseState ?: NotebookCellCollapseState ;
299
- }
300
-
301
- function serializeCell ( cell : NotebookCellTextModel ) : ISerializedCell {
302
- return {
303
- cellKind : cell . cellKind ,
304
- language : cell . language ,
305
- metadata : cell . metadata ,
306
- mime : cell . mime ,
307
- outputs : cell . outputs . map ( output => serializeCellOutput ( output ) ) ,
308
- source : cell . getValue ( )
309
- } ;
310
- }
311
-
312
- function deserializeCell ( cell : ISerializedCell ) : ICellDto2 {
313
- return {
314
- cellKind : cell . cellKind ,
315
- source : cell . source ,
316
- language : cell . language ,
317
- metadata : cell . metadata ,
318
- mime : cell . mime ,
319
- outputs : cell . outputs . map ( ( output ) => deserializeCellOutput ( output ) )
320
- } ;
321
- }
322
-
323
- function serializeCellOutput ( output : IOutputDto ) : ISerializedCellOutput {
324
- return {
325
- outputId : output . outputId ,
326
- outputs : output . outputs . map ( ot => ( {
327
- mime : ot . mime ,
328
- data : ot . data . buffer ? Array . from ( ot . data . buffer ) : [ ]
329
- } ) ) ,
330
- metadata : output . metadata
331
- } ;
332
- }
333
-
334
- function deserializeCellOutput ( output : ISerializedCellOutput ) : IOutputDto {
335
- return {
336
- outputId : output . outputId ,
337
- outputs : output . outputs . map ( ot => ( {
338
- mime : ot . mime ,
339
- data : VSBuffer . fromByteArray ( ot . data )
340
- } ) ) ,
341
- metadata : output . metadata
342
- } ;
343
- }
0 commit comments