mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
* Transfer notebook output data as a VSBuffer This PR transfers notebook output as an VSBuffer instead of as a array of numbers. This significantly reduces the message size as well as the serialize/deserialize times To accomplish this, I've introduced a new `SerializableObjectWithBuffers` type. This specially marks rpc objects that contain VSBuffers. This is needed as our current RPC implementation can only efficently transfer VSBuffers that appears as top level arguments. The rpcProtocol now can also identify top level `SerializableObjectWithBuffers` arguments and ensure these are serialized more efficently. This is easier than trying to extract the `VSBuffer` proeprties to top level arguments. It also lets us easily support return types that may contain buffers * use SerializableObjectWithBuffers when dealing with (old) notebook controllers Co-authored-by: Johannes Rieken <johannes.rieken@gmail.com>
51 lines
2.5 KiB
TypeScript
51 lines
2.5 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* 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 * as extHostProtocol from 'vs/workbench/api/common/extHost.protocol';
|
|
import { ExtHostNotebookController } from 'vs/workbench/api/common/extHostNotebook';
|
|
import { SerializableObjectWithBuffers } from 'vs/workbench/services/extensions/common/proxyIdentifier';
|
|
import type * as vscode from 'vscode';
|
|
|
|
export class ExtHostNotebookDocuments implements extHostProtocol.ExtHostNotebookDocumentsShape {
|
|
|
|
private readonly _onDidChangeNotebookDocumentMetadata = new Emitter<vscode.NotebookDocumentMetadataChangeEvent>();
|
|
readonly onDidChangeNotebookDocumentMetadata = this._onDidChangeNotebookDocumentMetadata.event;
|
|
|
|
private _onDidSaveNotebookDocument = new Emitter<vscode.NotebookDocument>();
|
|
readonly onDidSaveNotebookDocument = this._onDidSaveNotebookDocument.event;
|
|
|
|
constructor(
|
|
@ILogService private readonly _logService: ILogService,
|
|
private readonly _notebooksAndEditors: ExtHostNotebookController,
|
|
) { }
|
|
|
|
$acceptModelChanged(uri: UriComponents, event: SerializableObjectWithBuffers<extHostProtocol.NotebookCellsChangedEventDto>, isDirty: boolean): void {
|
|
const document = this._notebooksAndEditors.getNotebookDocument(URI.revive(uri));
|
|
document.acceptModelChanged(event.value, isDirty);
|
|
}
|
|
|
|
$acceptDirtyStateChanged(uri: UriComponents, isDirty: boolean): void {
|
|
const document = this._notebooksAndEditors.getNotebookDocument(URI.revive(uri));
|
|
document.acceptDirty(isDirty);
|
|
}
|
|
|
|
$acceptModelSaved(uri: UriComponents): void {
|
|
const document = this._notebooksAndEditors.getNotebookDocument(URI.revive(uri));
|
|
this._onDidSaveNotebookDocument.fire(document.apiNotebook);
|
|
}
|
|
|
|
$acceptDocumentPropertiesChanged(uri: UriComponents, data: extHostProtocol.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 });
|
|
}
|
|
}
|
|
}
|