diff --git a/src/sql/azdata.proposed.d.ts b/src/sql/azdata.proposed.d.ts index 1c649c7f9b..7f77cfbf10 100644 --- a/src/sql/azdata.proposed.d.ts +++ b/src/sql/azdata.proposed.d.ts @@ -4430,10 +4430,17 @@ declare module 'azdata' { */ cells: NotebookCell[]; /** - * The [change kind](#TextEditorSelectionChangeKind) which has triggered this + * The [change kind](#NotebookChangeKind) which has triggered this * event. Can be `undefined`. */ - kind?: vscode.TextEditorSelectionChangeKind; + kind?: NotebookChangeKind; + } + + export enum NotebookChangeKind { + ContentUpdated = 0, + MetadataUpdated = 1, + Save = 2, + CellExecuted = 3 } /** diff --git a/src/sql/workbench/api/common/sqlExtHostTypes.ts b/src/sql/workbench/api/common/sqlExtHostTypes.ts index 871a11442d..c661796174 100644 --- a/src/sql/workbench/api/common/sqlExtHostTypes.ts +++ b/src/sql/workbench/api/common/sqlExtHostTypes.ts @@ -645,4 +645,11 @@ export enum ColumnType { export enum ActionOnCellCheckboxCheck { selectRow = 0, customAction = 1 +} + +export enum NotebookChangeKind { + ContentUpdated = 0, + MetadataUpdated = 1, + Save = 2, + CellExecuted = 3 } \ No newline at end of file diff --git a/src/sql/workbench/api/node/extHostNotebookDocumentsAndEditors.ts b/src/sql/workbench/api/node/extHostNotebookDocumentsAndEditors.ts index db742e2b5b..5410ba10e2 100644 --- a/src/sql/workbench/api/node/extHostNotebookDocumentsAndEditors.ts +++ b/src/sql/workbench/api/node/extHostNotebookDocumentsAndEditors.ts @@ -147,7 +147,7 @@ export class ExtHostNotebookDocumentsAndEditors implements ExtHostNotebookDocume this._onDidChangeNotebookCell.fire({ cells: data.document.cells, notebook: data.document, - kind: undefined + kind: e.changeKind }); } } diff --git a/src/sql/workbench/api/node/mainThreadNotebookDocumentsAndEditors.ts b/src/sql/workbench/api/node/mainThreadNotebookDocumentsAndEditors.ts index 3a91454e9a..0285e1a31b 100644 --- a/src/sql/workbench/api/node/mainThreadNotebookDocumentsAndEditors.ts +++ b/src/sql/workbench/api/node/mainThreadNotebookDocumentsAndEditors.ts @@ -22,7 +22,7 @@ import { } from 'sql/workbench/api/node/sqlExtHost.protocol'; import { NotebookInput } from 'sql/workbench/parts/notebook/notebookInput'; import { INotebookService, INotebookEditor, IProviderInfo } from 'sql/workbench/services/notebook/common/notebookService'; -import { ISingleNotebookEditOperation } from 'sql/workbench/api/common/sqlExtHostTypes'; +import { ISingleNotebookEditOperation, NotebookChangeKind } from 'sql/workbench/api/common/sqlExtHostTypes'; import { disposed } from 'vs/base/common/errors'; import { ICellModel, NotebookContentChange, INotebookModel } from 'sql/workbench/parts/notebook/models/modelInterfaces'; import { NotebookChangeType, CellTypes } from 'sql/workbench/parts/notebook/models/contracts'; @@ -564,11 +564,32 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements providerId: editor.providerId, providers: editor.providers, uri: editor.uri, - kernelSpec: this.getKernelSpec(editor) + kernelSpec: this.getKernelSpec(editor), + changeKind: this.mapChangeKind(e.changeType) }; return changeData; } + mapChangeKind(changeType: NotebookChangeType): NotebookChangeKind { + switch (changeType) { + case NotebookChangeType.CellDeleted: + case NotebookChangeType.CellsAdded: + case NotebookChangeType.CellOutputUpdated: + case NotebookChangeType.CellSourceUpdated: + case NotebookChangeType.DirtyStateChanged: + return NotebookChangeKind.ContentUpdated; + case NotebookChangeType.KernelChanged: + case NotebookChangeType.TrustChanged: + return NotebookChangeKind.MetadataUpdated; + case NotebookChangeType.Saved: + return NotebookChangeKind.Save; + case NotebookChangeType.CellExecuted: + return NotebookChangeKind.CellExecuted; + default: + return NotebookChangeKind.ContentUpdated; + } + } + private getKernelSpec(editor: MainThreadNotebookEditor): azdata.nb.IKernelSpec { let spec = editor && editor.model && editor.model.clientSession ? editor.model.clientSession.cachedKernelSpec : undefined; return spec; diff --git a/src/sql/workbench/api/node/sqlExtHost.api.impl.ts b/src/sql/workbench/api/node/sqlExtHost.api.impl.ts index 1e8edcfd49..c5d2f9b134 100644 --- a/src/sql/workbench/api/node/sqlExtHost.api.impl.ts +++ b/src/sql/workbench/api/node/sqlExtHost.api.impl.ts @@ -496,7 +496,8 @@ export function createApiFactory( registerNotebookProvider(provider: azdata.nb.NotebookProvider): vscode.Disposable { return extHostNotebook.registerNotebookProvider(provider); }, - CellRange: sqlExtHostTypes.CellRange + CellRange: sqlExtHostTypes.CellRange, + NotebookChangeKind: sqlExtHostTypes.NotebookChangeKind }; return { diff --git a/src/sql/workbench/api/node/sqlExtHost.protocol.ts b/src/sql/workbench/api/node/sqlExtHost.protocol.ts index e7bda1b071..7ba79d456b 100644 --- a/src/sql/workbench/api/node/sqlExtHost.protocol.ts +++ b/src/sql/workbench/api/node/sqlExtHost.protocol.ts @@ -18,7 +18,9 @@ import { ITreeComponentItem } from 'sql/workbench/common/views'; import { ITaskHandlerDescription } from 'sql/platform/tasks/common/tasks'; import { IItemConfig, IComponentShape, IModelViewDialogDetails, IModelViewTabDetails, IModelViewButtonDetails, - IModelViewWizardDetails, IModelViewWizardPageDetails, INotebookManagerDetails, INotebookSessionDetails, INotebookKernelDetails, INotebookFutureDetails, FutureMessageType, INotebookFutureDone, ISingleNotebookEditOperation + IModelViewWizardDetails, IModelViewWizardPageDetails, INotebookManagerDetails, INotebookSessionDetails, + INotebookKernelDetails, INotebookFutureDetails, FutureMessageType, INotebookFutureDone, ISingleNotebookEditOperation, + NotebookChangeKind } from 'sql/workbench/api/common/sqlExtHostTypes'; import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor'; import { IUndoStopOptions } from 'vs/workbench/api/common/extHost.protocol'; @@ -870,6 +872,7 @@ export interface INotebookModelChangedData { isDirty: boolean; cells: azdata.nb.NotebookCell[]; kernelSpec: azdata.nb.IKernelSpec; + changeKind: NotebookChangeKind; } export interface INotebookEditorAddData { diff --git a/src/sql/workbench/parts/notebook/cellViews/output.component.ts b/src/sql/workbench/parts/notebook/cellViews/output.component.ts index dba650aada..636d4b7977 100644 --- a/src/sql/workbench/parts/notebook/cellViews/output.component.ts +++ b/src/sql/workbench/parts/notebook/cellViews/output.component.ts @@ -39,7 +39,7 @@ export class OutputComponent extends AngularDisposable implements OnInit { @Inject(IThemeService) private _themeService: IThemeService ) { super(); - this.registry = _notebookService.getMimeRegistry(); + this.registry = this._notebookService.getMimeRegistry(); } ngOnInit() { diff --git a/src/sql/workbench/parts/notebook/models/cell.ts b/src/sql/workbench/parts/notebook/models/cell.ts index c7e55a4b2a..ff7b053285 100644 --- a/src/sql/workbench/parts/notebook/models/cell.ts +++ b/src/sql/workbench/parts/notebook/models/cell.ts @@ -13,11 +13,13 @@ import * as notebookUtils from '../notebookUtils'; import { CellTypes, CellType, NotebookChangeType } from 'sql/workbench/parts/notebook/models/contracts'; import { NotebookModel } from 'sql/workbench/parts/notebook/models/notebookModel'; import { ICellModel, notebookConstants, IOutputChangedEvent } from 'sql/workbench/parts/notebook/models/modelInterfaces'; -import { ICellModelOptions, IModelFactory, FutureInternal, CellExecutionState } from './modelInterfaces'; +import { ICellModelOptions, FutureInternal, CellExecutionState } from './modelInterfaces'; import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement'; import { IConnectionProfile } from 'sql/platform/connection/common/interfaces'; import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; import { Schemas } from 'vs/base/common/network'; +import { INotebookService } from 'sql/workbench/services/notebook/common/notebookService'; +import { optional } from 'vs/platform/instantiation/common/instantiation'; let modelId = 0; export class CellModel implements ICellModel { @@ -39,7 +41,10 @@ export class CellModel implements ICellModel { private _connectionManagementService: IConnectionManagementService; private _stdInHandler: nb.MessageHandler; - constructor(private factory: IModelFactory, cellData?: nb.ICellContents, private _options?: ICellModelOptions) { + constructor(cellData: nb.ICellContents, + private _options: ICellModelOptions, + @optional(INotebookService) private _notebookService?: INotebookService + ) { this.id = `${modelId++}`; if (cellData) { // Read in contents if available @@ -178,6 +183,12 @@ export class CellModel implements ICellModel { this._onExecutionStateChanged.fire(this.executionState); } + private notifyExecutionComplete(): void { + if (this._notebookService) { + this._notebookService.serializeNotebookStateChange(this.notebookModel.notebookUri, NotebookChangeType.CellExecuted); + } + } + public get executionState(): CellExecutionState { let isRunning = !!(this._future && this._future.inProgress); if (isRunning) { @@ -256,6 +267,7 @@ export class CellModel implements ICellModel { } finally { this.disposeFuture(); this.fireExecutionStateChanged(); + this.notifyExecutionComplete(); } return true; diff --git a/src/sql/workbench/parts/notebook/models/contracts.ts b/src/sql/workbench/parts/notebook/models/contracts.ts index 0208e0c5ee..0ac832611b 100644 --- a/src/sql/workbench/parts/notebook/models/contracts.ts +++ b/src/sql/workbench/parts/notebook/models/contracts.ts @@ -43,5 +43,7 @@ export enum NotebookChangeType { CellOutputUpdated, DirtyStateChanged, KernelChanged, - TrustChanged + TrustChanged, + Saved, + CellExecuted } diff --git a/src/sql/workbench/parts/notebook/models/modelFactory.ts b/src/sql/workbench/parts/notebook/models/modelFactory.ts index 2e716c5ef1..1b616f005d 100644 --- a/src/sql/workbench/parts/notebook/models/modelFactory.ts +++ b/src/sql/workbench/parts/notebook/models/modelFactory.ts @@ -8,11 +8,15 @@ import { nb } from 'azdata'; import { CellModel } from './cell'; import { IClientSession, IClientSessionOptions, ICellModelOptions, ICellModel, IModelFactory } from './modelInterfaces'; import { ClientSession } from './clientSession'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; export class ModelFactory implements IModelFactory { + constructor(private instantiationService: IInstantiationService) { + + } public createCell(cell: nb.ICellContents, options: ICellModelOptions): ICellModel { - return new CellModel(this, cell, options); + return this.instantiationService.createInstance(CellModel, cell, options); } public createClientSession(options: IClientSessionOptions): IClientSession { diff --git a/src/sql/workbench/parts/notebook/models/modelInterfaces.ts b/src/sql/workbench/parts/notebook/models/modelInterfaces.ts index 397a73310f..521bcf0dff 100644 --- a/src/sql/workbench/parts/notebook/models/modelInterfaces.ts +++ b/src/sql/workbench/parts/notebook/models/modelInterfaces.ts @@ -401,6 +401,9 @@ export interface INotebookModel { /** Event fired once we get call back from ConfigureConnection method in sqlops extension */ readonly onValidConnectionSelected: Event; + + serializationStateChanged(changeType: NotebookChangeType): void; + } export interface NotebookContentChange { diff --git a/src/sql/workbench/parts/notebook/models/notebookModel.ts b/src/sql/workbench/parts/notebook/models/notebookModel.ts index 3abefd0890..e8cd2ade5a 100644 --- a/src/sql/workbench/parts/notebook/models/notebookModel.ts +++ b/src/sql/workbench/parts/notebook/models/notebookModel.ts @@ -954,4 +954,13 @@ export class NotebookModel extends Disposable implements INotebookModel { this._contentChangedEmitter.fire(changeInfo); } + serializationStateChanged(changeType: NotebookChangeType): void { + let changeInfo: NotebookContentChange = { + changeType: changeType, + cells: undefined + }; + + this._contentChangedEmitter.fire(changeInfo); + } + } diff --git a/src/sql/workbench/parts/notebook/notebook.component.ts b/src/sql/workbench/parts/notebook/notebook.component.ts index 5bc046dbff..71ca4c0b1c 100644 --- a/src/sql/workbench/parts/notebook/notebook.component.ts +++ b/src/sql/workbench/parts/notebook/notebook.component.ts @@ -345,7 +345,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe private get modelFactory(): IModelFactory { if (!this._notebookParams.modelFactory) { - this._notebookParams.modelFactory = new ModelFactory(); + this._notebookParams.modelFactory = new ModelFactory(this.instantiationService); } return this._notebookParams.modelFactory; } diff --git a/src/sql/workbench/parts/notebook/notebookInput.ts b/src/sql/workbench/parts/notebook/notebookInput.ts index b146391d52..247a71088a 100644 --- a/src/sql/workbench/parts/notebook/notebookInput.ts +++ b/src/sql/workbench/parts/notebook/notebookInput.ts @@ -11,7 +11,7 @@ import * as resources from 'vs/base/common/resources'; import * as azdata from 'azdata'; import { IStandardKernelWithProvider, getProvidersForFileName, getStandardKernelsForProvider } from 'sql/workbench/parts/notebook/notebookUtils'; -import { INotebookService, DEFAULT_NOTEBOOK_PROVIDER, IProviderInfo, SerializationStateChangeType } from 'sql/workbench/services/notebook/common/notebookService'; +import { INotebookService, DEFAULT_NOTEBOOK_PROVIDER, IProviderInfo } from 'sql/workbench/services/notebook/common/notebookService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; import { INotebookModel, IContentManager, NotebookContentChange } from 'sql/workbench/parts/notebook/models/modelInterfaces'; @@ -118,7 +118,7 @@ export class NotebookEditorModel extends EditorModel { private sendNotebookSerializationStateChange() { let notebookModel = this.getNotebookModel(); if (notebookModel) { - this.notebookService.serializeNotebookStateChange(this.notebookUri, SerializationStateChangeType.Saved); + this.notebookService.serializeNotebookStateChange(this.notebookUri, NotebookChangeType.Saved); } } @@ -127,7 +127,7 @@ export class NotebookEditorModel extends EditorModel { } private getNotebookModel(): INotebookModel { - let editor = this.notebookService.listNotebookEditors().find(n => n.id === this.notebookUri.toString()); + let editor = this.notebookService.findNotebookEditor(this.notebookUri); if (editor) { return editor.model; } diff --git a/src/sql/workbench/services/notebook/common/notebookService.ts b/src/sql/workbench/services/notebook/common/notebookService.ts index 1225285dbc..b16abf43df 100644 --- a/src/sql/workbench/services/notebook/common/notebookService.ts +++ b/src/sql/workbench/services/notebook/common/notebookService.ts @@ -15,6 +15,7 @@ import { IConnectionProfile } from 'sql/platform/connection/common/interfaces'; import { NotebookInput } from 'sql/workbench/parts/notebook/notebookInput'; import { ISingleNotebookEditOperation } from 'sql/workbench/api/common/sqlExtHostTypes'; import { ICellModel, INotebookModel, ILanguageMagic } from 'sql/workbench/parts/notebook/models/modelInterfaces'; +import { NotebookChangeType } from 'sql/workbench/parts/notebook/models/contracts'; export const SERVICE_ID = 'notebookService'; export const INotebookService = createDecorator(SERVICE_ID); @@ -65,6 +66,8 @@ export interface INotebookService { listNotebookEditors(): INotebookEditor[]; + findNotebookEditor(notebookUri: URI): INotebookEditor | undefined; + getMimeRegistry(): RenderMimeRegistry; renameNotebookEditor(oldUri: URI, newUri: URI, currentEditor: INotebookEditor): void; @@ -85,7 +88,7 @@ export interface INotebookService { * sent to listeners that can act on the point-in-time notebook state * @param notebookUri the URI identifying a notebook */ - serializeNotebookStateChange(notebookUri: URI, changeType: SerializationStateChangeType): void; + serializeNotebookStateChange(notebookUri: URI, changeType: NotebookChangeType): void; } @@ -128,8 +131,3 @@ export interface INotebookEditor { runAllCells(): Promise; clearAllOutputs(): Promise; } - -export enum SerializationStateChangeType { - Saved, - Executed -} \ No newline at end of file diff --git a/src/sql/workbench/services/notebook/common/notebookServiceImpl.ts b/src/sql/workbench/services/notebook/common/notebookServiceImpl.ts index 362bef6926..b9eab3af04 100644 --- a/src/sql/workbench/services/notebook/common/notebookServiceImpl.ts +++ b/src/sql/workbench/services/notebook/common/notebookServiceImpl.ts @@ -10,7 +10,7 @@ import { Registry } from 'vs/platform/registry/common/platform'; import { INotebookService, INotebookManager, INotebookProvider, - DEFAULT_NOTEBOOK_FILETYPE, INotebookEditor, SQL_NOTEBOOK_PROVIDER, OVERRIDE_EDITOR_THEMING_SETTING, SerializationStateChangeType + DEFAULT_NOTEBOOK_FILETYPE, INotebookEditor, SQL_NOTEBOOK_PROVIDER, OVERRIDE_EDITOR_THEMING_SETTING } from 'sql/workbench/services/notebook/common/notebookService'; import { RenderMimeRegistry } from 'sql/workbench/parts/notebook/outputs/registry'; import { standardRendererFactories } from 'sql/workbench/parts/notebook/outputs/factories'; @@ -40,6 +40,7 @@ import { RunOnceScheduler } from 'vs/base/common/async'; import { Schemas } from 'vs/base/common/network'; import { ILogService } from 'vs/platform/log/common/log'; import { toErrorMessage } from 'vs/base/common/errorMessage'; +import { NotebookChangeType } from 'sql/workbench/parts/notebook/models/contracts'; export interface NotebookProviderProperties { provider: string; @@ -384,6 +385,15 @@ export class NotebookService extends Disposable implements INotebookService { return editors; } + findNotebookEditor(notebookUri: URI): INotebookEditor | undefined { + if (!notebookUri) { + return undefined; + } + let uriString = notebookUri.toString(); + let editor = this.listNotebookEditors().find(n => n.id === uriString); + return editor; + } + renameNotebookEditor(oldUri: URI, newUri: URI, currentEditor: INotebookEditor): void { let oldUriKey = oldUri.toString(); if (this._editors.has(oldUriKey)) { @@ -552,7 +562,7 @@ export class NotebookService extends Disposable implements INotebookService { } } - serializeNotebookStateChange(notebookUri: URI, changeType: SerializationStateChangeType): void { + serializeNotebookStateChange(notebookUri: URI, changeType: NotebookChangeType): void { if (notebookUri.scheme !== Schemas.untitled) { // Conditions for saving: // 1. Not untitled. They're always trusted as we open them @@ -560,7 +570,7 @@ export class NotebookService extends Disposable implements INotebookService { // 3. Not already saving (e.g. isn't in the queue to be cached) // 4. Notebook is trusted. Don't need to save state of untrusted notebooks let notebookUriString = notebookUri.toString(); - if (changeType === SerializationStateChangeType.Saved && this._trustedCacheQueue.findIndex(uri => uri.toString() === notebookUriString) < 0) { + if (changeType === NotebookChangeType.Saved && this._trustedCacheQueue.findIndex(uri => uri.toString() === notebookUriString) < 0) { // Only save if it's trusted let notebook = this.listNotebookEditors().find(n => n.id === notebookUriString); if (notebook && notebook.model.trustedMode) { @@ -568,6 +578,11 @@ export class NotebookService extends Disposable implements INotebookService { this._updateTrustCacheScheduler.schedule(); } } + } + + let editor = this.findNotebookEditor(notebookUri); + if (editor && editor.model) { + editor.model.serializationStateChanged(changeType); // TODO add history notification if a non-untitled notebook has a state change } } diff --git a/src/sqltest/parts/notebook/common.ts b/src/sqltest/parts/notebook/common.ts index 7f45a7dce0..684d1293fb 100644 --- a/src/sqltest/parts/notebook/common.ts +++ b/src/sqltest/parts/notebook/common.ts @@ -102,6 +102,9 @@ export class NotebookModelStub implements INotebookModel { toJSON(): nb.INotebookContents { throw new Error('Method not implemented.'); } + serializationStateChanged(changeType: NotebookChangeType): void { + throw new Error('Method not implemented.'); + } } export class NotebookManagerStub implements INotebookManager { diff --git a/src/sqltest/parts/notebook/model/cell.test.ts b/src/sqltest/parts/notebook/model/cell.test.ts index 07b4f84736..f2f84d0c29 100644 --- a/src/sqltest/parts/notebook/model/cell.test.ts +++ b/src/sqltest/parts/notebook/model/cell.test.ts @@ -15,9 +15,17 @@ import { NotebookModelStub } from '../common'; import { EmptyFuture } from 'sql/workbench/services/notebook/common/sessionManager'; import { ICellModel } from 'sql/workbench/parts/notebook/models/modelInterfaces'; import { Deferred } from 'sql/base/common/promise'; +import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; + +let instantiationService: IInstantiationService; suite('Cell Model', function (): void { - let factory = new ModelFactory(); + let serviceCollection = new ServiceCollection(); + instantiationService = new InstantiationService(serviceCollection, true); + + let factory = new ModelFactory(instantiationService); test('Should set default values if none defined', async function (): Promise { let cell = factory.createCell(undefined, undefined); should(cell.cellType).equal(CellTypes.Code); diff --git a/src/sqltest/parts/notebook/model/notebookModel.test.ts b/src/sqltest/parts/notebook/model/notebookModel.test.ts index 2122027a58..8e9ab8d545 100644 --- a/src/sqltest/parts/notebook/model/notebookModel.test.ts +++ b/src/sqltest/parts/notebook/model/notebookModel.test.ts @@ -25,6 +25,9 @@ import { Emitter } from 'vs/base/common/event'; import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService'; import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService'; import { TestStorageService, TestLogService } from 'vs/workbench/test/workbenchTestServices'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; +import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; let expectedNotebookContent: nb.INotebookContents = { cells: [{ @@ -72,6 +75,7 @@ let sessionReady: Deferred; let mockModelFactory: TypeMoq.Mock; let notificationService: TypeMoq.Mock; let capabilitiesService: TypeMoq.Mock; +let instantiationService: IInstantiationService; suite('notebook model', function (): void { let notebookManagers = [new NotebookManagerStub()]; @@ -87,9 +91,11 @@ suite('notebook model', function (): void { memento.setup(x => x.getMemento(TypeMoq.It.isAny())).returns(() => void 0); queryConnectionService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined, new TestStorageService()); queryConnectionService.callBase = true; + let serviceCollection = new ServiceCollection(); + instantiationService = new InstantiationService(serviceCollection, true); defaultModelOptions = { notebookUri: defaultUri, - factory: new ModelFactory(), + factory: new ModelFactory(instantiationService), notebookManagers, contentManager: undefined, notificationService: notificationService.object, diff --git a/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts b/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts index 8a4bc5d66b..599e294b9f 100644 --- a/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts +++ b/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts @@ -54,8 +54,8 @@ class NotebookUpdateParticipant implements ISaveParticipantParticipant { } public participate(model: ITextFileEditorModel, env: { reason: SaveReason }): Promise { - let uriString = model.getResource().toString(); - let notebookEditor = this.notebookService.listNotebookEditors().find((editor) => editor.id === uriString); + let uri = model.getResource(); + let notebookEditor = this.notebookService.findNotebookEditor(uri); if (notebookEditor) { notebookEditor.notebookParams.input.updateModel(); }