diff --git a/src/vs/workbench/api/common/extHostDocumentSaveParticipant.ts b/src/vs/workbench/api/common/extHostDocumentSaveParticipant.ts index 7a90e5db0f916..de3123da9de25 100644 --- a/src/vs/workbench/api/common/extHostDocumentSaveParticipant.ts +++ b/src/vs/workbench/api/common/extHostDocumentSaveParticipant.ts @@ -15,6 +15,7 @@ import type * as vscode from 'vscode'; import { LinkedList } from 'vs/base/common/linkedList'; import { ILogService } from 'vs/platform/log/common/log'; import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'; +import { SerializableObjectWithBuffers } from 'vs/workbench/services/extensions/common/proxyIdentifier'; type Listener = [Function, any, IExtensionDescription]; @@ -165,7 +166,7 @@ export class ExtHostDocumentSaveParticipant implements ExtHostDocumentSavePartic } if (version === document.version) { - return this._mainThreadBulkEdits.$tryApplyWorkspaceEdit(dto); + return this._mainThreadBulkEdits.$tryApplyWorkspaceEdit(new SerializableObjectWithBuffers(dto)); } return Promise.reject(new Error('concurrent_edits')); diff --git a/src/vs/workbench/api/common/extHostNotebookDocumentSaveParticipant.ts b/src/vs/workbench/api/common/extHostNotebookDocumentSaveParticipant.ts index 1e6a706a3058f..0f031e2f76b7d 100644 --- a/src/vs/workbench/api/common/extHostNotebookDocumentSaveParticipant.ts +++ b/src/vs/workbench/api/common/extHostNotebookDocumentSaveParticipant.ts @@ -13,6 +13,7 @@ import { ExtHostNotebookController } from 'vs/workbench/api/common/extHostNotebo import { TextDocumentSaveReason, WorkspaceEdit as WorksapceEditConverter } from 'vs/workbench/api/common/extHostTypeConverters'; import { WorkspaceEdit } from 'vs/workbench/api/common/extHostTypes'; import { SaveReason } from 'vs/workbench/common/editor'; +import { SerializableObjectWithBuffers } from 'vs/workbench/services/extensions/common/proxyIdentifier'; import { NotebookDocumentWillSaveEvent } from 'vscode'; interface IExtensionListener { @@ -90,6 +91,6 @@ export class ExtHostNotebookDocumentSaveParticipant implements ExtHostNotebookDo dto.edits = dto.edits.concat(edits); } - return this._mainThreadBulkEdits.$tryApplyWorkspaceEdit(dto); + return this._mainThreadBulkEdits.$tryApplyWorkspaceEdit(new SerializableObjectWithBuffers(dto)); } } diff --git a/src/vs/workbench/api/test/browser/extHostBulkEdits.test.ts b/src/vs/workbench/api/test/browser/extHostBulkEdits.test.ts index f17a6c5b0e96c..045f3d77cc136 100644 --- a/src/vs/workbench/api/test/browser/extHostBulkEdits.test.ts +++ b/src/vs/workbench/api/test/browser/extHostBulkEdits.test.ts @@ -13,6 +13,7 @@ import { NullLogService } from 'vs/platform/log/common/log'; import { ExtHostBulkEdits } from 'vs/workbench/api/common/extHostBulkEdits'; import { nullExtensionDescription } from 'vs/workbench/services/extensions/common/extensions'; import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils'; +import { SerializableObjectWithBuffers } from 'vs/workbench/services/extensions/common/proxyIdentifier'; suite('ExtHostBulkEdits.applyWorkspaceEdit', () => { @@ -25,8 +26,8 @@ suite('ExtHostBulkEdits.applyWorkspaceEdit', () => { const rpcProtocol = new TestRPCProtocol(); rpcProtocol.set(MainContext.MainThreadBulkEdits, new class extends mock() { - override $tryApplyWorkspaceEdit(_workspaceResourceEdits: IWorkspaceEditDto): Promise { - workspaceResourceEdits = _workspaceResourceEdits; + override $tryApplyWorkspaceEdit(_workspaceResourceEdits: SerializableObjectWithBuffers): Promise { + workspaceResourceEdits = _workspaceResourceEdits.value; return Promise.resolve(true); } }); diff --git a/src/vs/workbench/api/test/browser/extHostDocumentSaveParticipant.test.ts b/src/vs/workbench/api/test/browser/extHostDocumentSaveParticipant.test.ts index 59c02e4d3b1d6..632487d43c0a3 100644 --- a/src/vs/workbench/api/test/browser/extHostDocumentSaveParticipant.test.ts +++ b/src/vs/workbench/api/test/browser/extHostDocumentSaveParticipant.test.ts @@ -16,6 +16,7 @@ import { mock } from 'vs/base/test/common/mock'; import { NullLogService } from 'vs/platform/log/common/log'; import { nullExtensionDescription } from 'vs/workbench/services/extensions/common/extensions'; import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils'; +import { SerializableObjectWithBuffers } from 'vs/workbench/services/extensions/common/proxyIdentifier'; function timeout(n: number) { return new Promise(resolve => setTimeout(resolve, n)); @@ -257,8 +258,8 @@ suite('ExtHostDocumentSaveParticipant', () => { let dto: IWorkspaceEditDto; const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, new class extends mock() { - $tryApplyWorkspaceEdit(_edits: IWorkspaceEditDto) { - dto = _edits; + $tryApplyWorkspaceEdit(_edits: SerializableObjectWithBuffers) { + dto = _edits.value; return Promise.resolve(true); } }); @@ -281,8 +282,8 @@ suite('ExtHostDocumentSaveParticipant', () => { let edits: IWorkspaceEditDto; const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, new class extends mock() { - $tryApplyWorkspaceEdit(_edits: IWorkspaceEditDto) { - edits = _edits; + $tryApplyWorkspaceEdit(_edits: SerializableObjectWithBuffers) { + edits = _edits.value; return Promise.resolve(true); } }); @@ -318,9 +319,9 @@ suite('ExtHostDocumentSaveParticipant', () => { test('event delivery, two listeners -> two document states', () => { const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, new class extends mock() { - $tryApplyWorkspaceEdit(dto: IWorkspaceEditDto) { + $tryApplyWorkspaceEdit(dto: SerializableObjectWithBuffers) { - for (const edit of dto.edits) { + for (const edit of dto.value.edits) { const uri = URI.revive((edit).resource); const { text, range } = (edit).textEdit; diff --git a/src/vs/workbench/api/test/browser/mainThreadEditors.test.ts b/src/vs/workbench/api/test/browser/mainThreadEditors.test.ts index 78d484a667db8..9809814a6c032 100644 --- a/src/vs/workbench/api/test/browser/mainThreadEditors.test.ts +++ b/src/vs/workbench/api/test/browser/mainThreadEditors.test.ts @@ -48,6 +48,7 @@ import { BulkEditService } from 'vs/workbench/contrib/bulkEdit/browser/bulkEditS import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { SerializableObjectWithBuffers } from 'vs/workbench/services/extensions/common/proxyIdentifier'; import { LabelService } from 'vs/workbench/services/label/common/labelService'; import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle'; import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/browser/panecomposite'; @@ -204,7 +205,7 @@ suite('MainThreadEditors', () => { // Act as if the user edited the model model.applyEdits([EditOperation.insert(new Position(0, 0), 'something')]); - return bulkEdits.$tryApplyWorkspaceEdit({ edits: [workspaceResourceEdit] }).then((result) => { + return bulkEdits.$tryApplyWorkspaceEdit(new SerializableObjectWithBuffers({ edits: [workspaceResourceEdit] })).then((result) => { assert.strictEqual(result, false); }); }); @@ -230,11 +231,11 @@ suite('MainThreadEditors', () => { } }; - const p1 = bulkEdits.$tryApplyWorkspaceEdit({ edits: [workspaceResourceEdit1] }).then((result) => { + const p1 = bulkEdits.$tryApplyWorkspaceEdit(new SerializableObjectWithBuffers({ edits: [workspaceResourceEdit1] })).then((result) => { // first edit request succeeds assert.strictEqual(result, true); }); - const p2 = bulkEdits.$tryApplyWorkspaceEdit({ edits: [workspaceResourceEdit2] }).then((result) => { + const p2 = bulkEdits.$tryApplyWorkspaceEdit(new SerializableObjectWithBuffers({ edits: [workspaceResourceEdit2] })).then((result) => { // second edit request fails assert.strictEqual(result, false); }); @@ -242,13 +243,13 @@ suite('MainThreadEditors', () => { }); test(`applyWorkspaceEdit with only resource edit`, () => { - return bulkEdits.$tryApplyWorkspaceEdit({ + return bulkEdits.$tryApplyWorkspaceEdit(new SerializableObjectWithBuffers({ edits: [ { oldResource: resource, newResource: resource, options: undefined }, { oldResource: undefined, newResource: resource, options: undefined }, { oldResource: resource, newResource: undefined, options: undefined } ] - }).then((result) => { + })).then((result) => { assert.strictEqual(result, true); assert.strictEqual(movedResources.get(resource), resource); assert.strictEqual(createdResources.has(resource), true);