提交 71fd93bf 编写于 作者: R rebornix

Cell.source

上级 24cac8b4
......@@ -1683,7 +1683,7 @@ declare module 'vscode' {
language: string;
cellKind: CellKind;
outputs: CellOutput[];
getContent(): string;
source: string;
metadata?: NotebookCellMetadata;
}
......
......@@ -1531,7 +1531,6 @@ export interface ExtHostCommentsShape {
export interface ExtHostNotebookShape {
$resolveNotebook(viewType: string, uri: UriComponents): Promise<number | undefined>;
$executeNotebook(viewType: string, uri: UriComponents, cellHandle: number | undefined): Promise<void>;
$deleteCell(viewType: string, uri: UriComponents, index: number): Promise<boolean>;
$saveNotebook(viewType: string, uri: UriComponents): Promise<boolean>;
$updateActiveEditor(viewType: string, uri: UriComponents): Promise<void>;
$destoryNotebookDocument(viewType: string, uri: UriComponents): Promise<boolean>;
......
......@@ -24,7 +24,7 @@ const notebookDocumentMetadataDefaults: vscode.NotebookDocumentMetadata = {
export class ExtHostCell implements vscode.NotebookCell {
public source: string[];
private originalSource: string[];
private _outputs: any[];
private _onDidChangeOutputs = new Emitter<ISplice<vscode.CellOutput>[]>();
onDidChangeOutputs: Event<ISplice<vscode.CellOutput>[]> = this._onDidChangeOutputs.event;
......@@ -32,6 +32,14 @@ export class ExtHostCell implements vscode.NotebookCell {
private _initalVersion: number = -1;
private _outputMapping = new Set<vscode.CellOutput>();
get source() {
if (this._textDocument && this._initalVersion !== this._textDocument?.version) {
return this._textDocument.getText();
} else {
return this.originalSource.join('\n');
}
}
constructor(
private viewType: string,
private documentUri: URI,
......@@ -44,7 +52,7 @@ export class ExtHostCell implements vscode.NotebookCell {
private _metadata: vscode.NotebookCellMetadata | undefined,
private _proxy: MainThreadNotebookShape
) {
this.source = this._content.split(/\r|\n|\r\n/g);
this.originalSource = this._content.split(/\r|\n|\r\n/g);
this._outputs = outputs;
}
......@@ -89,7 +97,7 @@ export class ExtHostCell implements vscode.NotebookCell {
if (this._textDocument && this._initalVersion !== this._textDocument?.version) {
return this._textDocument.getText();
} else {
return this.source.join('\n');
return this.originalSource.join('\n');
}
}
......@@ -100,7 +108,7 @@ export class ExtHostCell implements vscode.NotebookCell {
detachTextDocument() {
if (this._textDocument && this._textDocument.version !== this._initalVersion) {
this.source = this._textDocument.getText().split(/\r|\n|\r\n/g);
this.originalSource = this._textDocument.getText().split(/\r|\n|\r\n/g);
}
this._textDocument = undefined;
......@@ -244,20 +252,6 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
this._proxy.$spliceNotebookCellOutputs(this.viewType, this.uri, cell.handle, outputDtos, Array.from(renderers));
}
deleteCell(index: number): boolean {
if (index >= this.cells.length) {
return false;
}
let cell = this.cells[index];
this._cellDisposableMapping.get(cell.handle)?.dispose();
this._cellDisposableMapping.delete(cell.handle);
this.cells.splice(index, 1);
return true;
}
transformMimeTypes(cell: vscode.NotebookCell, output: vscode.CellDisplayOutput): ITransformedDisplayOutputDto {
let mimeTypes = Object.keys(output.data);
......@@ -665,22 +659,6 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
return provider.provider.executeCell(document!, cell);
}
async $deleteCell(viewType: string, uri: UriComponents, index: number): Promise<boolean> {
let provider = this._notebookProviders.get(viewType);
if (!provider) {
return false;
}
let document = this._documents.get(URI.revive(uri).toString());
if (document) {
return document.deleteCell(index);
}
return false;
}
async $saveNotebook(viewType: string, uri: UriComponents): Promise<boolean> {
let provider = this._notebookProviders.get(viewType);
let document = this._documents.get(URI.revive(uri).toString());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册