mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 09:08:53 +01:00
add TextDocument#notebook api proposal, https://github.com/microsoft/vscode/issues/100890
This commit is contained in:
@@ -17,7 +17,7 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'
|
||||
import { CellKind, ExtHostNotebookShape, IMainContext, IModelAddedData, INotebookDocumentsAndEditorsDelta, INotebookEditorPropertiesChangeData, MainContext, MainThreadNotebookShape, NotebookCellOutputsSplice } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import { ExtHostDocumentsAndEditors, IExtHostModelAddedData } 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';
|
||||
@@ -61,14 +61,15 @@ const addIdToOutput = (output: IRawOutput, id = UUID.generateUuid()): IProcessed
|
||||
|
||||
export class ExtHostCell extends Disposable implements vscode.NotebookCell {
|
||||
|
||||
public static asModelAddData(cell: IMainCellDto): IModelAddedData {
|
||||
public static asModelAddData(notebook: ExtHostNotebookDocument, cell: IMainCellDto): IExtHostModelAddedData {
|
||||
return {
|
||||
EOL: cell.eol,
|
||||
lines: cell.source,
|
||||
modeId: cell.language,
|
||||
uri: cell.uri,
|
||||
isDirty: false,
|
||||
versionId: 1
|
||||
versionId: 1,
|
||||
notebook
|
||||
};
|
||||
}
|
||||
|
||||
@@ -363,7 +364,7 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
|
||||
}
|
||||
|
||||
const contentChangeEvents: vscode.NotebookCellsChangeData[] = [];
|
||||
const addedCellDocuments: IModelAddedData[] = [];
|
||||
const addedCellDocuments: IExtHostModelAddedData[] = [];
|
||||
|
||||
splices.reverse().forEach(splice => {
|
||||
const cellDtos = splice[2];
|
||||
@@ -372,7 +373,7 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
|
||||
const extCell = new ExtHostCell(this._proxy, this, this._documentsAndEditors, cell);
|
||||
|
||||
if (!initialization) {
|
||||
addedCellDocuments.push(ExtHostCell.asModelAddData(cell));
|
||||
addedCellDocuments.push(ExtHostCell.asModelAddData(this, cell));
|
||||
}
|
||||
|
||||
if (!this._cellDisposableMapping.has(extCell.handle)) {
|
||||
@@ -404,7 +405,7 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
|
||||
});
|
||||
|
||||
if (addedCellDocuments) {
|
||||
this._documentsAndEditors.$acceptDocumentsAndEditorsDelta({ addedDocuments: addedCellDocuments });
|
||||
this._documentsAndEditors.acceptDocumentsAndEditorsDelta({ addedDocuments: addedCellDocuments });
|
||||
}
|
||||
|
||||
if (!initialization) {
|
||||
@@ -1588,7 +1589,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
|
||||
});
|
||||
|
||||
// add cell document as vscode.TextDocument
|
||||
addedCellDocuments.push(...modelData.cells.map(ExtHostCell.asModelAddData));
|
||||
addedCellDocuments.push(...modelData.cells.map(cell => ExtHostCell.asModelAddData(document, cell)));
|
||||
|
||||
this._documents.get(revivedUri)?.dispose();
|
||||
this._documents.set(revivedUri, document);
|
||||
@@ -1600,9 +1601,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
|
||||
}
|
||||
}
|
||||
|
||||
this._documentsAndEditors.$acceptDocumentsAndEditorsDelta({
|
||||
addedDocuments: addedCellDocuments
|
||||
});
|
||||
this._documentsAndEditors.$acceptDocumentsAndEditorsDelta({ addedDocuments: addedCellDocuments });
|
||||
|
||||
const document = this._documents.get(revivedUri)!;
|
||||
this._onDidOpenNotebookDocument.fire(document);
|
||||
|
||||
Reference in New Issue
Block a user