From 660ffebf0a886f91e930121275b2b9cced300363 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Fri, 17 Jul 2020 18:23:16 +0200 Subject: [PATCH] always send model add data and check on the extension if this is a notebook-cell special case this sends the twice but gurantees that the renderer owns the model --- .../api/browser/mainThreadDocumentsAndEditors.ts | 7 +------ .../workbench/api/common/extHostDocumentsAndEditors.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.ts b/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.ts index 537fc580a31..5f69d9ee9bc 100644 --- a/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.ts +++ b/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.ts @@ -30,7 +30,6 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/ import { IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/common/workingCopyFileService'; import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; -import { Schemas } from 'vs/base/common/network'; namespace delta { @@ -400,12 +399,8 @@ export class MainThreadDocumentsAndEditors { extHostDelta.removedEditors = removedEditors; } if (delta.addedDocuments.length > 0) { - // notebook cell documents get sync'd by the notebook open logic - // and therefore we don't send them another time now. empty = false; - extHostDelta.addedDocuments = delta.addedDocuments - .filter(m => m.uri.scheme !== Schemas.vscodeNotebookCell) - .map(m => this._toModelAddData(m)); + extHostDelta.addedDocuments = delta.addedDocuments.map(m => this._toModelAddData(m)); } if (delta.addedEditors.length > 0) { empty = false; diff --git a/src/vs/workbench/api/common/extHostDocumentsAndEditors.ts b/src/vs/workbench/api/common/extHostDocumentsAndEditors.ts index bf3919a0841..63fc98becaa 100644 --- a/src/vs/workbench/api/common/extHostDocumentsAndEditors.ts +++ b/src/vs/workbench/api/common/extHostDocumentsAndEditors.ts @@ -15,6 +15,7 @@ import { ExtHostTextEditor } from 'vs/workbench/api/common/extHostTextEditor'; import * as typeConverters from 'vs/workbench/api/common/extHostTypeConverters'; import { ILogService } from 'vs/platform/log/common/log'; import { ResourceMap } from 'vs/base/common/map'; +import { Schemas } from 'vs/base/common/network'; export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsShape { @@ -60,7 +61,14 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha if (delta.addedDocuments) { for (const data of delta.addedDocuments) { const resource = URI.revive(data.uri); - assert.ok(!this._documents.has(resource), `document '${resource} already exists!'`); + const existingDocumentData = this._documents.get(resource); + if (existingDocumentData) { + if (resource.scheme !== Schemas.vscodeNotebookCell) { + throw new Error(`document '${resource} already exists!'`); + } + existingDocumentData.onEvents({ changes: [], versionId: data.versionId, eol: data.EOL }); + continue; + } const documentData = new ExtHostDocumentData( this._extHostRpc.getProxy(MainContext.MainThreadDocuments),