diff --git a/src/vs/workbench/api/browser/mainThreadNotebookDocuments.ts b/src/vs/workbench/api/browser/mainThreadNotebookDocuments.ts index 4fbe1ac207f..9646fac588c 100644 --- a/src/vs/workbench/api/browser/mainThreadNotebookDocuments.ts +++ b/src/vs/workbench/api/browser/mainThreadNotebookDocuments.ts @@ -13,7 +13,7 @@ import { IImmediateCellEditOperation, IMainCellDto, NotebookCellsChangeType, Not import { INotebookEditorModelResolverService } from 'vs/workbench/contrib/notebook/common/notebookEditorModelResolverService'; import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService'; import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity'; -import { ExtHostContext, ExtHostNotebookShape, IExtHostContext, MainThreadNotebookDocumentsShape } from '../common/extHost.protocol'; +import { ExtHostContext, ExtHostNotebookDocumentsShape, IExtHostContext, MainThreadNotebookDocumentsShape } from '../common/extHost.protocol'; import { MainThreadNotebooksAndEditors } from 'vs/workbench/api/browser/mainThreadNotebookDocumentsAndEditors'; import { onUnexpectedError } from 'vs/base/common/errors'; import { Schemas } from 'vs/base/common/network'; @@ -23,7 +23,7 @@ export class MainThreadNotebookDocuments implements MainThreadNotebookDocumentsS private readonly _disposables = new DisposableStore(); - private readonly _proxy: ExtHostNotebookShape; + private readonly _proxy: ExtHostNotebookDocumentsShape; private readonly _documentEventListenersMapping = new ResourceMap(); private readonly _modelReferenceCollection: BoundModelReferenceCollection; @@ -34,7 +34,7 @@ export class MainThreadNotebookDocuments implements MainThreadNotebookDocumentsS @INotebookEditorModelResolverService private readonly _notebookEditorModelResolverService: INotebookEditorModelResolverService, @IUriIdentityService private readonly _uriIdentityService: IUriIdentityService ) { - this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostNotebook); + this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostNotebookDocuments); this._modelReferenceCollection = new BoundModelReferenceCollection(this._uriIdentityService.extUri); notebooksAndEditors.onDidAddNotebooks(this._handleNotebooksAdded, this, this._disposables); diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index cdefe3a5a04..63eebb8e833 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -89,6 +89,7 @@ import { ExtHostNotebookRenderers } from 'vs/workbench/api/common/extHostNoteboo import { Schemas } from 'vs/base/common/network'; import { matchesScheme } from 'vs/platform/opener/common/opener'; import { ExtHostNotebookEditors } from 'vs/workbench/api/common/extHostNotebookEditors'; +import { ExtHostNotebookDocuments } from 'vs/workbench/api/common/extHostNotebookDocuments'; export interface IExtensionApiFactory { (extension: IExtensionDescription, registry: ExtensionDescriptionRegistry, configProvider: ExtHostConfigProvider): typeof vscode; @@ -146,7 +147,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I const extHostDocuments = rpcProtocol.set(ExtHostContext.ExtHostDocuments, new ExtHostDocuments(rpcProtocol, extHostDocumentsAndEditors)); const extHostDocumentContentProviders = rpcProtocol.set(ExtHostContext.ExtHostDocumentContentProviders, new ExtHostDocumentContentProvider(rpcProtocol, extHostDocumentsAndEditors, extHostLogService)); const extHostDocumentSaveParticipant = rpcProtocol.set(ExtHostContext.ExtHostDocumentSaveParticipant, new ExtHostDocumentSaveParticipant(extHostLogService, extHostDocuments, rpcProtocol.getProxy(MainContext.MainThreadBulkEdits))); - const extHostNotebook = rpcProtocol.set(ExtHostContext.ExtHostNotebook, new ExtHostNotebookController(rpcProtocol, extHostCommands, extHostDocumentsAndEditors, extHostDocuments, extHostLogService, extensionStoragePaths)); + const extHostNotebook = rpcProtocol.set(ExtHostContext.ExtHostNotebook, new ExtHostNotebookController(rpcProtocol, extHostCommands, extHostDocumentsAndEditors, extHostDocuments, extensionStoragePaths)); + const extHostNotebookDocuments = rpcProtocol.set(ExtHostContext.ExtHostNotebookDocuments, new ExtHostNotebookDocuments(extHostLogService, extHostNotebook)); const extHostNotebookEditors = rpcProtocol.set(ExtHostContext.ExtHostNotebookEditors, new ExtHostNotebookEditors(extHostLogService, rpcProtocol, extHostNotebook)); const extHostNotebookKernels = rpcProtocol.set(ExtHostContext.ExtHostNotebookKernels, new ExtHostNotebookKernels(rpcProtocol, initData, extHostNotebook, extHostLogService)); const extHostNotebookRenderers = rpcProtocol.set(ExtHostContext.ExtHostNotebookRenderers, new ExtHostNotebookRenderers(rpcProtocol, extHostNotebook)); @@ -1099,7 +1101,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I }, get onDidSaveNotebookDocument(): Event { checkProposedApiEnabled(extension); - return extHostNotebook.onDidSaveNotebookDocument; + return extHostNotebookDocuments.onDidSaveNotebookDocument; }, createNotebookEditorDecorationType(options: vscode.NotebookDecorationRenderOptions): vscode.NotebookEditorDecorationType { checkProposedApiEnabled(extension); @@ -1111,7 +1113,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I }, onDidChangeNotebookDocumentMetadata(listener, thisArgs?, disposables?) { checkProposedApiEnabled(extension); - return extHostNotebook.onDidChangeNotebookDocumentMetadata(listener, thisArgs, disposables); + return extHostNotebookDocuments.onDidChangeNotebookDocumentMetadata(listener, thisArgs, disposables); }, onDidChangeNotebookCells(listener, thisArgs?, disposables?) { checkProposedApiEnabled(extension); diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 07850c4c4f6..f93362a38f0 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -1910,7 +1910,7 @@ export interface INotebookDocumentsAndEditorsDelta { visibleEditors?: string[]; } -export interface ExtHostNotebookShape extends ExtHostNotebookDocumentsAndEditorsShape, ExtHostNotebookDocumentsShape { +export interface ExtHostNotebookShape extends ExtHostNotebookDocumentsAndEditorsShape { $provideNotebookCellStatusBarItems(handle: number, uri: UriComponents, index: number, token: CancellationToken): Promise; $releaseNotebookCellStatusBarItems(id: number): void; @@ -2127,6 +2127,7 @@ export const ExtHostContext = { ExtHostOutputService: createMainId('ExtHostOutputService'), ExtHosLabelService: createMainId('ExtHostLabelService'), ExtHostNotebook: createMainId('ExtHostNotebook'), + ExtHostNotebookDocuments: createMainId('ExtHostNotebookDocuments'), ExtHostNotebookEditors: createMainId('ExtHostNotebookEditors'), ExtHostNotebookKernels: createMainId('ExtHostNotebookKernels'), ExtHostNotebookRenderers: createMainId('ExtHostNotebookRenderers'), diff --git a/src/vs/workbench/api/common/extHostNotebook.ts b/src/vs/workbench/api/common/extHostNotebook.ts index f5268f45390..3646ae59882 100644 --- a/src/vs/workbench/api/common/extHostNotebook.ts +++ b/src/vs/workbench/api/common/extHostNotebook.ts @@ -14,16 +14,15 @@ import { isFalsyOrWhitespace } from 'vs/base/common/strings'; import { assertIsDefined } from 'vs/base/common/types'; import { URI, UriComponents } from 'vs/base/common/uri'; import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'; -import { ILogService } from 'vs/platform/log/common/log'; import { Cache } from 'vs/workbench/api/common/cache'; -import { ExtHostNotebookShape, IMainContext, IModelAddedData, INotebookCellStatusBarListDto, INotebookDocumentPropertiesChangeData, INotebookDocumentsAndEditorsDelta, INotebookDocumentShowOptions, INotebookEditorAddData, MainContext, MainThreadNotebookDocumentsShape, MainThreadNotebookEditorsShape, MainThreadNotebookShape } from 'vs/workbench/api/common/extHost.protocol'; +import { ExtHostNotebookShape, IMainContext, IModelAddedData, INotebookCellStatusBarListDto, INotebookDocumentsAndEditorsDelta, INotebookDocumentShowOptions, INotebookEditorAddData, MainContext, MainThreadNotebookDocumentsShape, MainThreadNotebookEditorsShape, MainThreadNotebookShape } from 'vs/workbench/api/common/extHost.protocol'; import { CommandsConverter, ExtHostCommands } from 'vs/workbench/api/common/extHostCommands'; import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments'; import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors'; import { IExtensionStoragePaths } from 'vs/workbench/api/common/extHostStoragePaths'; import * as typeConverters from 'vs/workbench/api/common/extHostTypeConverters'; import * as extHostTypes from 'vs/workbench/api/common/extHostTypes'; -import { INotebookExclusiveDocumentFilter, INotebookContributionData, NotebookCellsChangedEventDto, NotebookCellsChangeType, NotebookDataDto } from 'vs/workbench/contrib/notebook/common/notebookCommon'; +import { INotebookExclusiveDocumentFilter, INotebookContributionData, NotebookCellsChangeType, NotebookDataDto } from 'vs/workbench/contrib/notebook/common/notebookCommon'; import type * as vscode from 'vscode'; import { ExtHostCell, ExtHostNotebookDocument } from './extHostNotebookDocument'; import { ExtHostNotebookEditor } from './extHostNotebookEditor'; @@ -47,8 +46,6 @@ export class ExtHostNotebookController implements ExtHostNotebookShape { private readonly _editors = new Map(); private readonly _commandsConverter: CommandsConverter; - private readonly _onDidChangeNotebookDocumentMetadata = new Emitter(); - readonly onDidChangeNotebookDocumentMetadata = this._onDidChangeNotebookDocumentMetadata.event; private readonly _onDidChangeNotebookCells = new Emitter(); readonly onDidChangeNotebookCells = this._onDidChangeNotebookCells.event; private readonly _onDidChangeCellOutputs = new Emitter(); @@ -73,8 +70,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape { onDidOpenNotebookDocument: Event = this._onDidOpenNotebookDocument.event; private _onDidCloseNotebookDocument = new Emitter(); onDidCloseNotebookDocument: Event = this._onDidCloseNotebookDocument.event; - private _onDidSaveNotebookDocument = new Emitter(); - onDidSaveNotebookDocument: Event = this._onDidSaveNotebookDocument.event; + private _onDidChangeVisibleNotebookEditors = new Emitter(); onDidChangeVisibleNotebookEditors = this._onDidChangeVisibleNotebookEditors.event; @@ -85,7 +81,6 @@ export class ExtHostNotebookController implements ExtHostNotebookShape { commands: ExtHostCommands, private _textDocumentsAndEditors: ExtHostDocumentsAndEditors, private _textDocuments: ExtHostDocuments, - private readonly logService: ILogService, private readonly _extensionStoragePaths: IExtensionStoragePaths, ) { this._notebookProxy = mainContext.getProxy(MainContext.MainThreadNotebook); @@ -402,29 +397,6 @@ export class ExtHostNotebookController implements ExtHostNotebookShape { return backup.id; } - $acceptModelChanged(uri: UriComponents, event: NotebookCellsChangedEventDto, isDirty: boolean): void { - const document = this.getNotebookDocument(URI.revive(uri)); - document.acceptModelChanged(event, isDirty); - } - - $acceptDirtyStateChanged(uri: UriComponents, isDirty: boolean): void { - const document = this.getNotebookDocument(URI.revive(uri)); - document.acceptModelChanged({ rawEvents: [], versionId: document.apiNotebook.version }, isDirty); - } - - $acceptModelSaved(uri: UriComponents): void { - const document = this.getNotebookDocument(URI.revive(uri)); - this._onDidSaveNotebookDocument.fire(document.apiNotebook); - } - - $acceptDocumentPropertiesChanged(uri: UriComponents, data: INotebookDocumentPropertiesChangeData): void { - this.logService.debug('ExtHostNotebook#$acceptDocumentPropertiesChanged', uri.path, data); - const document = this.getNotebookDocument(URI.revive(uri)); - document.acceptDocumentPropertiesChanged(data); - if (data.metadata) { - this._onDidChangeNotebookDocumentMetadata.fire({ document: document.apiNotebook }); - } - } private _createExtHostEditor(document: ExtHostNotebookDocument, editorId: string, data: INotebookEditorAddData) { diff --git a/src/vs/workbench/api/common/extHostNotebookDocuments.ts b/src/vs/workbench/api/common/extHostNotebookDocuments.ts new file mode 100644 index 00000000000..b5db1c40fa7 --- /dev/null +++ b/src/vs/workbench/api/common/extHostNotebookDocuments.ts @@ -0,0 +1,50 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { Emitter } from 'vs/base/common/event'; +import { URI, UriComponents } from 'vs/base/common/uri'; +import { ILogService } from 'vs/platform/log/common/log'; +import { ExtHostNotebookDocumentsShape, INotebookDocumentPropertiesChangeData } from 'vs/workbench/api/common/extHost.protocol'; +import { ExtHostNotebookController } from 'vs/workbench/api/common/extHostNotebook'; +import { NotebookCellsChangedEventDto } from 'vs/workbench/contrib/notebook/common/notebookCommon'; +import type * as vscode from 'vscode'; + +export class ExtHostNotebookDocuments implements ExtHostNotebookDocumentsShape { + + private readonly _onDidChangeNotebookDocumentMetadata = new Emitter(); + readonly onDidChangeNotebookDocumentMetadata = this._onDidChangeNotebookDocumentMetadata.event; + + private _onDidSaveNotebookDocument = new Emitter(); + readonly onDidSaveNotebookDocument = this._onDidSaveNotebookDocument.event; + + constructor( + @ILogService private readonly _logService: ILogService, + private readonly _notebooksAndEditors: ExtHostNotebookController, + ) { } + + $acceptModelChanged(uri: UriComponents, event: NotebookCellsChangedEventDto, isDirty: boolean): void { + const document = this._notebooksAndEditors.getNotebookDocument(URI.revive(uri)); + document.acceptModelChanged(event, isDirty); + } + + $acceptDirtyStateChanged(uri: UriComponents, isDirty: boolean): void { + const document = this._notebooksAndEditors.getNotebookDocument(URI.revive(uri)); + document.acceptModelChanged({ rawEvents: [], versionId: document.apiNotebook.version }, isDirty); + } + + $acceptModelSaved(uri: UriComponents): void { + const document = this._notebooksAndEditors.getNotebookDocument(URI.revive(uri)); + this._onDidSaveNotebookDocument.fire(document.apiNotebook); + } + + $acceptDocumentPropertiesChanged(uri: UriComponents, data: INotebookDocumentPropertiesChangeData): void { + this._logService.debug('ExtHostNotebook#$acceptDocumentPropertiesChanged', uri.path, data); + const document = this._notebooksAndEditors.getNotebookDocument(URI.revive(uri)); + document.acceptDocumentPropertiesChanged(data); + if (data.metadata) { + this._onDidChangeNotebookDocumentMetadata.fire({ document: document.apiNotebook }); + } + } +} diff --git a/src/vs/workbench/test/browser/api/extHostNotebook.test.ts b/src/vs/workbench/test/browser/api/extHostNotebook.test.ts index edc23df29ae..79c6a109595 100644 --- a/src/vs/workbench/test/browser/api/extHostNotebook.test.ts +++ b/src/vs/workbench/test/browser/api/extHostNotebook.test.ts @@ -22,6 +22,7 @@ import { isEqual } from 'vs/base/common/resources'; import { IExtensionStoragePaths } from 'vs/workbench/api/common/extHostStoragePaths'; import { generateUuid } from 'vs/base/common/uuid'; import { Event } from 'vs/base/common/event'; +import { ExtHostNotebookDocuments } from 'vs/workbench/api/common/extHostNotebookDocuments'; suite('NotebookCell#Document', function () { @@ -31,6 +32,8 @@ suite('NotebookCell#Document', function () { let extHostDocumentsAndEditors: ExtHostDocumentsAndEditors; let extHostDocuments: ExtHostDocuments; let extHostNotebooks: ExtHostNotebookController; + let extHostNotebookDocuments: ExtHostNotebookDocuments; + const notebookUri = URI.parse('test:///notebook.file'); const disposables = new DisposableStore(); @@ -54,7 +57,9 @@ suite('NotebookCell#Document', function () { return URI.from({ scheme: 'test', path: generateUuid() }); } }; - extHostNotebooks = new ExtHostNotebookController(rpcProtocol, new ExtHostCommands(rpcProtocol, new NullLogService()), extHostDocumentsAndEditors, extHostDocuments, new NullLogService(), extHostStoragePaths); + extHostNotebooks = new ExtHostNotebookController(rpcProtocol, new ExtHostCommands(rpcProtocol, new NullLogService()), extHostDocumentsAndEditors, extHostDocuments, extHostStoragePaths); + extHostNotebookDocuments = new ExtHostNotebookDocuments(new NullLogService(), extHostNotebooks); + let reg = extHostNotebooks.registerNotebookContentProvider(nullExtensionDescription, 'test', new class extends mock() { // async openNotebook() { } }); @@ -162,7 +167,7 @@ suite('NotebookCell#Document', function () { }); }); - extHostNotebooks.$acceptModelChanged(notebookUri, { + extHostNotebookDocuments.$acceptModelChanged(notebookUri, { versionId: notebook.apiNotebook.version + 1, rawEvents: [ { @@ -238,7 +243,7 @@ suite('NotebookCell#Document', function () { assert.strictEqual(notebook.apiNotebook.cellCount, 2); const [cell1, cell2] = notebook.apiNotebook.getCells(); - extHostNotebooks.$acceptModelChanged(notebook.uri, { + extHostNotebookDocuments.$acceptModelChanged(notebook.uri, { versionId: 2, rawEvents: [ { @@ -269,7 +274,7 @@ suite('NotebookCell#Document', function () { assert.strictEqual(second.index, 1); // remove first cell - extHostNotebooks.$acceptModelChanged(notebook.uri, { + extHostNotebookDocuments.$acceptModelChanged(notebook.uri, { versionId: notebook.apiNotebook.version + 1, rawEvents: [{ kind: NotebookCellsChangeType.ModelChange, @@ -280,7 +285,7 @@ suite('NotebookCell#Document', function () { assert.strictEqual(notebook.apiNotebook.cellCount, 1); assert.strictEqual(second.index, 0); - extHostNotebooks.$acceptModelChanged(notebookUri, { + extHostNotebookDocuments.$acceptModelChanged(notebookUri, { versionId: notebook.apiNotebook.version + 1, rawEvents: [{ kind: NotebookCellsChangeType.ModelChange, @@ -315,7 +320,7 @@ suite('NotebookCell#Document', function () { // DON'T call this, make sure the cell-documents have not been created yet // assert.strictEqual(notebook.notebookDocument.cellCount, 2); - extHostNotebooks.$acceptModelChanged(notebook.uri, { + extHostNotebookDocuments.$acceptModelChanged(notebook.uri, { versionId: 100, rawEvents: [{ kind: NotebookCellsChangeType.ModelChange, @@ -398,7 +403,7 @@ suite('NotebookCell#Document', function () { const removed = Event.toPromise(extHostDocuments.onDidRemoveDocument); const added = Event.toPromise(extHostDocuments.onDidAddDocument); - extHostNotebooks.$acceptModelChanged(notebook.uri, { + extHostNotebookDocuments.$acceptModelChanged(notebook.uri, { versionId: 12, rawEvents: [{ kind: NotebookCellsChangeType.ChangeLanguage, index: 0, diff --git a/src/vs/workbench/test/browser/api/extHostNotebookConcatDocument.test.ts b/src/vs/workbench/test/browser/api/extHostNotebookConcatDocument.test.ts index 5d523de220a..c38867cc9eb 100644 --- a/src/vs/workbench/test/browser/api/extHostNotebookConcatDocument.test.ts +++ b/src/vs/workbench/test/browser/api/extHostNotebookConcatDocument.test.ts @@ -22,6 +22,7 @@ import { MainContext, MainThreadCommandsShape, MainThreadNotebookShape } from 'v import { DisposableStore } from 'vs/base/common/lifecycle'; import { IExtensionStoragePaths } from 'vs/workbench/api/common/extHostStoragePaths'; import { generateUuid } from 'vs/base/common/uuid'; +import { ExtHostNotebookDocuments } from 'vs/workbench/api/common/extHostNotebookDocuments'; suite('NotebookConcatDocument', function () { @@ -30,6 +31,8 @@ suite('NotebookConcatDocument', function () { let extHostDocumentsAndEditors: ExtHostDocumentsAndEditors; let extHostDocuments: ExtHostDocuments; let extHostNotebooks: ExtHostNotebookController; + let extHostNotebookDocuments: ExtHostNotebookDocuments; + const notebookUri = URI.parse('test:///notebook.file'); const disposables = new DisposableStore(); @@ -51,7 +54,9 @@ suite('NotebookConcatDocument', function () { return URI.from({ scheme: 'test', path: generateUuid() }); } }; - extHostNotebooks = new ExtHostNotebookController(rpcProtocol, new ExtHostCommands(rpcProtocol, new NullLogService()), extHostDocumentsAndEditors, extHostDocuments, new NullLogService(), extHostStoragePaths); + extHostNotebooks = new ExtHostNotebookController(rpcProtocol, new ExtHostCommands(rpcProtocol, new NullLogService()), extHostDocumentsAndEditors, extHostDocuments, extHostStoragePaths); + extHostNotebookDocuments = new ExtHostNotebookDocuments(new NullLogService(), extHostNotebooks); + let reg = extHostNotebooks.registerNotebookContentProvider(nullExtensionDescription, 'test', new class extends mock() { // async openNotebook() { } }); @@ -122,7 +127,7 @@ suite('NotebookConcatDocument', function () { const cellUri1 = CellUri.generate(notebook.uri, 1); const cellUri2 = CellUri.generate(notebook.uri, 2); - extHostNotebooks.$acceptModelChanged(notebookUri, { + extHostNotebookDocuments.$acceptModelChanged(notebookUri, { versionId: notebook.apiNotebook.version + 1, rawEvents: [{ kind: NotebookCellsChangeType.ModelChange, @@ -159,7 +164,7 @@ suite('NotebookConcatDocument', function () { test('location, position mapping', function () { - extHostNotebooks.$acceptModelChanged(notebookUri, { + extHostNotebookDocuments.$acceptModelChanged(notebookUri, { versionId: notebook.apiNotebook.version + 1, rawEvents: [ { @@ -204,7 +209,7 @@ suite('NotebookConcatDocument', function () { let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.apiNotebook, undefined); // UPDATE 1 - extHostNotebooks.$acceptModelChanged(notebookUri, { + extHostNotebookDocuments.$acceptModelChanged(notebookUri, { versionId: notebook.apiNotebook.version + 1, rawEvents: [ { @@ -231,7 +236,7 @@ suite('NotebookConcatDocument', function () { // UPDATE 2 - extHostNotebooks.$acceptModelChanged(notebookUri, { + extHostNotebookDocuments.$acceptModelChanged(notebookUri, { versionId: notebook.apiNotebook.version + 1, rawEvents: [ { @@ -259,7 +264,7 @@ suite('NotebookConcatDocument', function () { assertLocation(doc, new Position(5, 12), new Location(notebook.apiNotebook.cellAt(1).document.uri, new Position(2, 11)), false); // don't check identity because position will be clamped // UPDATE 3 (remove cell #2 again) - extHostNotebooks.$acceptModelChanged(notebookUri, { + extHostNotebookDocuments.$acceptModelChanged(notebookUri, { versionId: notebook.apiNotebook.version + 1, rawEvents: [ { @@ -281,7 +286,7 @@ suite('NotebookConcatDocument', function () { let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.apiNotebook, undefined); // UPDATE 1 - extHostNotebooks.$acceptModelChanged(notebookUri, { + extHostNotebookDocuments.$acceptModelChanged(notebookUri, { versionId: notebook.apiNotebook.version + 1, rawEvents: [ { @@ -340,7 +345,7 @@ suite('NotebookConcatDocument', function () { test('selector', function () { - extHostNotebooks.$acceptModelChanged(notebookUri, { + extHostNotebookDocuments.$acceptModelChanged(notebookUri, { versionId: notebook.apiNotebook.version + 1, rawEvents: [ { @@ -374,7 +379,7 @@ suite('NotebookConcatDocument', function () { assertLines(fooLangDoc, 'fooLang-document'); assertLines(barLangDoc, 'barLang-document'); - extHostNotebooks.$acceptModelChanged(notebookUri, { + extHostNotebookDocuments.$acceptModelChanged(notebookUri, { versionId: notebook.apiNotebook.version + 1, rawEvents: [ { @@ -412,7 +417,7 @@ suite('NotebookConcatDocument', function () { test('offsetAt(position) <-> positionAt(offset)', function () { - extHostNotebooks.$acceptModelChanged(notebookUri, { + extHostNotebookDocuments.$acceptModelChanged(notebookUri, { versionId: notebook.apiNotebook.version + 1, rawEvents: [ { @@ -469,7 +474,7 @@ suite('NotebookConcatDocument', function () { test('locationAt(position) <-> positionAt(location)', function () { - extHostNotebooks.$acceptModelChanged(notebookUri, { + extHostNotebookDocuments.$acceptModelChanged(notebookUri, { versionId: notebook.apiNotebook.version + 1, rawEvents: [ { @@ -510,7 +515,7 @@ suite('NotebookConcatDocument', function () { test('getText(range)', function () { - extHostNotebooks.$acceptModelChanged(notebookUri, { + extHostNotebookDocuments.$acceptModelChanged(notebookUri, { versionId: notebook.apiNotebook.version + 1, rawEvents: [ { @@ -548,7 +553,7 @@ suite('NotebookConcatDocument', function () { test('validateRange/Position', function () { - extHostNotebooks.$acceptModelChanged(notebookUri, { + extHostNotebookDocuments.$acceptModelChanged(notebookUri, { versionId: notebook.apiNotebook.version + 1, rawEvents: [ { diff --git a/src/vs/workbench/test/browser/api/extHostNotebookKernel2.test.ts b/src/vs/workbench/test/browser/api/extHostNotebookKernel2.test.ts index 4fe7cde00ce..a82287eac4b 100644 --- a/src/vs/workbench/test/browser/api/extHostNotebookKernel2.test.ts +++ b/src/vs/workbench/test/browser/api/extHostNotebookKernel2.test.ts @@ -22,6 +22,7 @@ import { generateUuid } from 'vs/base/common/uuid'; import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands'; import { CellKind, CellUri, NotebookCellsChangeType } from 'vs/workbench/contrib/notebook/common/notebookCommon'; import { DisposableStore } from 'vs/base/common/lifecycle'; +import { ExtHostNotebookDocuments } from 'vs/workbench/api/common/extHostNotebookDocuments'; suite('NotebookKernel', function () { @@ -31,6 +32,7 @@ suite('NotebookKernel', function () { let extHostDocumentsAndEditors: ExtHostDocumentsAndEditors; let extHostDocuments: ExtHostDocuments; let extHostNotebooks: ExtHostNotebookController; + let extHostNotebookDocuments: ExtHostNotebookDocuments; const notebookUri = URI.parse('test:///notebook.file'); const kernelData = new Map(); @@ -71,7 +73,9 @@ suite('NotebookKernel', function () { return URI.from({ scheme: 'test', path: generateUuid() }); } }; - extHostNotebooks = new ExtHostNotebookController(rpcProtocol, new ExtHostCommands(rpcProtocol, new NullLogService()), extHostDocumentsAndEditors, extHostDocuments, new NullLogService(), extHostStoragePaths); + extHostNotebooks = new ExtHostNotebookController(rpcProtocol, new ExtHostCommands(rpcProtocol, new NullLogService()), extHostDocumentsAndEditors, extHostDocuments, extHostStoragePaths); + + extHostNotebookDocuments = new ExtHostNotebookDocuments(new NullLogService(), extHostNotebooks); extHostNotebooks.$acceptDocumentAndEditorsDelta({ addedDocuments: [{ @@ -192,7 +196,7 @@ suite('NotebookKernel', function () { const cell1 = notebook.apiNotebook.cellAt(0); extHostNotebookKernels.$acceptNotebookAssociation(0, notebook.uri, true); - extHostNotebooks.$acceptModelChanged(notebook.uri, { + extHostNotebookDocuments.$acceptModelChanged(notebook.uri, { versionId: 12, rawEvents: [{ kind: NotebookCellsChangeType.ModelChange,