Skip to content

Commit 367c538

Browse files
committed
drop one-off IW backup/recovery mechanism
1 parent b8e7f2b commit 367c538

File tree

2 files changed

+5
-126
lines changed

2 files changed

+5
-126
lines changed

src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { PLAINTEXT_LANGUAGE_ID } from 'vs/editor/common/languages/modesRegistry'
1919
import { ITextModel } from 'vs/editor/common/model';
2020
import { IModelService } from 'vs/editor/common/services/model';
2121
import { ITextModelContentProvider, ITextModelService } from 'vs/editor/common/services/resolverService';
22-
import { peekViewBorder /*, peekViewEditorBackground, peekViewResultsBackground */ } from 'vs/editor/contrib/peekView/browser/peekView';
22+
import { peekViewBorder } from 'vs/editor/contrib/peekView/browser/peekView';
2323
import { Context as SuggestContext } from 'vs/editor/contrib/suggest/browser/suggest';
2424
import { localize } from 'vs/nls';
2525
import { ILocalizedString } from 'vs/platform/action/common/action';
@@ -28,7 +28,6 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
2828
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
2929
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
3030
import { EditorActivation, IResourceEditorInput } from 'vs/platform/editor/common/editor';
31-
import { IFileService } from 'vs/platform/files/common/files';
3231
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
3332
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
3433
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
@@ -41,7 +40,6 @@ import { EditorPaneDescriptor, IEditorPaneRegistry } from 'vs/workbench/browser/
4140
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
4241
import { EditorExtensions, EditorsOrder, IEditorFactoryRegistry, IEditorSerializer } from 'vs/workbench/common/editor';
4342
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
44-
// import { Color } from 'vs/base/common/color';
4543
import { PANEL_BORDER } from 'vs/workbench/common/theme';
4644
import { ResourceNotebookCellEdit } from 'vs/workbench/contrib/bulkEdit/browser/bulkCellEdits';
4745
import { InteractiveWindowSetting, INTERACTIVE_INPUT_CURSOR_BOUNDARY } from 'vs/workbench/contrib/interactive/browser/interactiveCommon';
@@ -83,9 +81,7 @@ export class InteractiveDocumentContribution extends Disposable implements IWork
8381
constructor(
8482
@INotebookService notebookService: INotebookService,
8583
@IEditorResolverService editorResolverService: IEditorResolverService,
86-
@IEditorService editorService: IEditorService,
87-
@IFileService fileService: IFileService,
88-
@ILogService logService: ILogService
84+
@IEditorService editorService: IEditorService
8985
) {
9086
super();
9187

@@ -252,8 +248,7 @@ export class InteractiveEditorSerializer implements IEditorSerializer {
252248
return JSON.stringify({
253249
resource: input.primary.resource,
254250
inputResource: input.inputResource,
255-
name: input.getName(),
256-
data: input.getSerialization()
251+
name: input.getName()
257252
});
258253
}
259254

@@ -272,7 +267,6 @@ export class InteractiveEditorSerializer implements IEditorSerializer {
272267
}
273268

274269
const input = InteractiveEditorInput.create(instantiationService, resource, inputResource);
275-
input.restoreSerialization(data.data);
276270
return input;
277271
}
278272
}

src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.ts

Lines changed: 2 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { VSBuffer } from 'vs/base/common/buffer';
76
import { Event } from 'vs/base/common/event';
87
import { IReference } from 'vs/base/common/lifecycle';
98
import * as paths from 'vs/base/common/path';
@@ -16,9 +15,7 @@ import { EditorInputCapabilities, GroupIdentifier, ISaveOptions, IUntypedEditorI
1615
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
1716
import { IInteractiveDocumentService } from 'vs/workbench/contrib/interactive/browser/interactiveDocumentService';
1817
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';
2219
import { ICompositeNotebookEditorInput, NotebookEditorInput } from 'vs/workbench/contrib/notebook/common/notebookEditorInput';
2320
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
2421

@@ -139,13 +136,7 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
139136
return this._inputResolver;
140137
}
141138

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();
149140

150141
return this._inputResolver;
151142
}
@@ -158,10 +149,6 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
158149
this._interactiveDocumentService.willCreateInteractiveDocument(this.resource!, this.inputResource, language);
159150
this._inputModelRef = await this._textModelService.createModelReference(this.inputResource);
160151

161-
if (this._data && this._data.inputData) {
162-
this._inputModelRef.object.textEditorModel.setValue(this._data.inputData.value);
163-
}
164-
165152
return this._inputModelRef.object.textEditorModel;
166153
}
167154

@@ -222,37 +209,6 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
222209
return basename.substr(0, basename.length - paths.extname(p).length);
223210
}
224211

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-
256212
override dispose() {
257213
// we support closing the interactive window without prompt, so the editor model should not be dirty
258214
this._editorModelReference?.revert({ soft: true });
@@ -270,74 +226,3 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
270226
return this._historyService;
271227
}
272228
}
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

Comments
 (0)