提交 e437d424 编写于 作者: R rebornix

fix #129629.

上级 01a874ac
......@@ -90,7 +90,7 @@ export class CustomEditorInputSerializer extends WebviewEditorInputSerializer {
): CustomEditorInput {
const data = this.fromJson(JSON.parse(serializedEditorInput));
if (data.viewType === 'jupyter.notebook.ipynb') {
return NotebookEditorInput.create(this._instantiationService, data.editorResource, 'jupyter-notebook', { _backupId: data.backupId }) as any;
return NotebookEditorInput.create(this._instantiationService, data.editorResource, 'jupyter-notebook', { _backupId: data.backupId, startDirty: data.dirty }) as any;
}
const webview = reviveWebview(this._webviewService, data);
......@@ -164,7 +164,7 @@ export class ComplexCustomWorkingCopyEditorHandler extends Disposable implements
const backupData = backup.meta;
if (backupData.viewType === 'jupyter.notebook.ipynb') {
return NotebookEditorInput.create(this._instantiationService, URI.revive(backupData.editorResource), 'jupyter-notebook', { _backupId: backupData.backupId, _workingCopy: workingCopy }) as any;
return NotebookEditorInput.create(this._instantiationService, URI.revive(backupData.editorResource), 'jupyter-notebook', { startDirty: !!backupData.backupId, _backupId: backupData.backupId, _workingCopy: workingCopy }) as any;
}
const id = backupData.webview.id;
......
......@@ -27,7 +27,7 @@ import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchCo
import { IEditorInput, IEditorSerializer, IEditorFactoryRegistry, IEditorInputWithOptions, EditorExtensions } from 'vs/workbench/common/editor';
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
import { NotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookEditor';
import { isCompositeNotebookEditorInput, NotebookEditorInput } from 'vs/workbench/contrib/notebook/common/notebookEditorInput';
import { isCompositeNotebookEditorInput, NotebookEditorInput, NotebookEditorInputOptions } from 'vs/workbench/contrib/notebook/common/notebookEditorInput';
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
import { NotebookService } from 'vs/workbench/contrib/notebook/browser/notebookServiceImpl';
import { CellKind, CellToolbarLocation, CellToolbarVisibility, CellUri, DisplayOrderKey, UndoRedoPerCell, IResolvedNotebookEditorModel, NotebookDocumentBackupData, NotebookTextDiffEditorPreview, NotebookWorkingCopyTypeIdentifier, ShowCellStatusBar, CompactView, FocusIndicator, InsertToolbarLocation, GlobalToolbar, ConsolidatedOutputButton, ShowFoldingControls, DragAndDropEnabled, NotebookCellEditorOptionsCustomizations, ConsolidatedRunButton, TextOutputLineLimit } from 'vs/workbench/contrib/notebook/common/notebookCommon';
......@@ -151,7 +151,7 @@ class NotebookDiffEditorSerializer implements IEditorSerializer {
}
}
type SerializedNotebookEditorData = { resource: URI, viewType: string };
type SerializedNotebookEditorData = { resource: URI, viewType: string, options?: NotebookEditorInputOptions };
class NotebookEditorSerializer implements IEditorSerializer {
canSerialize(): boolean {
return true;
......@@ -160,7 +160,8 @@ class NotebookEditorSerializer implements IEditorSerializer {
assertType(input instanceof NotebookEditorInput);
const data: SerializedNotebookEditorData = {
resource: input.resource,
viewType: input.viewType
viewType: input.viewType,
options: input.options
};
return JSON.stringify(data);
}
......@@ -169,12 +170,12 @@ class NotebookEditorSerializer implements IEditorSerializer {
if (!data) {
return undefined;
}
const { resource, viewType } = data;
const { resource, viewType, options } = data;
if (!data || !URI.isUri(resource) || typeof viewType !== 'string') {
return undefined;
}
const input = NotebookEditorInput.create(instantiationService, resource, viewType);
const input = NotebookEditorInput.create(instantiationService, resource, viewType, options);
return input;
}
}
......
......@@ -12,7 +12,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
import { INotebookEditorModelResolverService } from 'vs/workbench/contrib/notebook/common/notebookEditorModelResolverService';
import { IDisposable, IReference } from 'vs/base/common/lifecycle';
import { IResolvedNotebookEditorModel } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { CellEditType, IResolvedNotebookEditorModel } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { ILabelService } from 'vs/platform/label/common/label';
import { Schemas } from 'vs/base/common/network';
import { mark } from 'vs/workbench/contrib/notebook/common/notebookPerformance';
......@@ -24,7 +24,7 @@ import { VSBuffer } from 'vs/base/common/buffer';
import { IWorkingCopyIdentifier } from 'vs/workbench/services/workingCopy/common/workingCopy';
import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackup';
interface NotebookEditorInputOptions {
export interface NotebookEditorInputOptions {
startDirty?: boolean;
/**
* backupId for webview
......@@ -248,10 +248,20 @@ export class NotebookEditorInput extends AbstractResourceEditorInput {
}
const data = await info.serializer.dataToNotebook(VSBuffer.fromString(JSON.stringify({ __webview_backup: this.options._backupId })));
this._editorModelReference.object.notebook._initialize(data.cells, true);
this._editorModelReference.object.notebook.applyEdits([
{
editType: CellEditType.Replace,
index: 0,
count: this._editorModelReference.object.notebook.length,
cells: data.cells
}
], true, undefined, () => undefined, undefined, false);
if (this.options._workingCopy) {
await this.workingCopyBackupService.discardBackup(this.options._workingCopy);
this.options._backupId = undefined;
this.options._workingCopy = undefined;
this.options.startDirty = undefined;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册