Skip to content

Commit 06377cf

Browse files
committed
NotebookEditorEdit-api changes, #105283
1 parent ef4df1d commit 06377cf

File tree

2 files changed

+13
-42
lines changed

2 files changed

+13
-42
lines changed

src/vs/vscode.proposed.d.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,21 +1405,10 @@ declare module 'vscode' {
14051405
}
14061406

14071407
export interface NotebookEditorEdit {
1408-
1409-
replaceNotebookMetadata(value: NotebookDocumentMetadata): void;
1410-
1408+
replaceMetadata(value: NotebookDocumentMetadata): void;
14111409
replaceCells(start: number, end: number, cells: NotebookCellData[]): void;
14121410
replaceCellOutput(index: number, outputs: CellOutput[]): void;
14131411
replaceCellMetadata(index: number, metadata: NotebookCellMetadata): void;
1414-
1415-
/** @deprecated */
1416-
replaceOutput(index: number, outputs: CellOutput[]): void;
1417-
/** @deprecated */
1418-
replaceMetadata(index: number, metadata: NotebookCellMetadata): void;
1419-
/** @deprecated */
1420-
insert(index: number, content: string | string[], language: string, type: CellKind, outputs: CellOutput[], metadata: NotebookCellMetadata | undefined): void;
1421-
/** @deprecated */
1422-
delete(index: number): void;
14231412
}
14241413

14251414
export interface NotebookCellRange {
@@ -1503,6 +1492,16 @@ declare module 'vscode' {
15031492
*/
15041493
asWebviewUri(localResource: Uri): Uri;
15051494

1495+
/**
1496+
* Perform an edit on the notebook associated with this notebook editor.
1497+
*
1498+
* The given callback-function is invoked with an [edit-builder](#NotebookEditorEdit) which must
1499+
* be used to make edits. Note that the edit-builder is only valid while the
1500+
* callback executes.
1501+
*
1502+
* @param callback A function which can create edits using an [edit-builder](#NotebookEditorEdit).
1503+
* @return A promise that resolves with a value indicating if the edits could be applied.
1504+
*/
15061505
edit(callback: (editBuilder: NotebookEditorEdit) => void): Thenable<boolean>;
15071506

15081507
revealRange(range: NotebookCellRange, revealType?: NotebookEditorRevealType): void;

src/vs/workbench/api/common/extHostNotebookEditor.ts

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { readonly } from 'vs/base/common/errors';
77
import { Emitter, Event } from 'vs/base/common/event';
88
import { Disposable } from 'vs/base/common/lifecycle';
9-
import { CellKind, MainThreadNotebookShape } from 'vs/workbench/api/common/extHost.protocol';
9+
import { MainThreadNotebookShape } from 'vs/workbench/api/common/extHost.protocol';
1010
import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
1111
import { addIdToOutput, CellEditType, ICellEditOperation, ICellReplaceEdit, INotebookEditData, notebookDocumentMetadataDefaults } from 'vs/workbench/contrib/notebook/common/notebookCommon';
1212
import * as vscode from 'vscode';
@@ -37,7 +37,7 @@ class NotebookEditorCellEditBuilder implements vscode.NotebookEditorEdit {
3737
}
3838
}
3939

40-
replaceNotebookMetadata(value: vscode.NotebookDocumentMetadata): void {
40+
replaceMetadata(value: vscode.NotebookDocumentMetadata): void {
4141
this._throwIfFinalized();
4242
this._collectedEdits.push({
4343
editType: CellEditType.DocumentMetadata,
@@ -54,12 +54,6 @@ class NotebookEditorCellEditBuilder implements vscode.NotebookEditorEdit {
5454
});
5555
}
5656

57-
replaceMetadata(index: number, metadata: vscode.NotebookCellMetadata): void {
58-
console.warn('DEPRECATED use "replaceCellMetadata" instead');
59-
this.replaceCellMetadata(index, metadata);
60-
}
61-
62-
6357
replaceCellOutput(index: number, outputs: vscode.CellOutput[]): void {
6458
this._throwIfFinalized();
6559
this._collectedEdits.push({
@@ -69,14 +63,8 @@ class NotebookEditorCellEditBuilder implements vscode.NotebookEditorEdit {
6963
});
7064
}
7165

72-
replaceOutput(index: number, outputs: vscode.CellOutput[]): void {
73-
console.warn('DEPRECATED use "replaceCellOutput" instead');
74-
this.replaceCellOutput(index, outputs);
75-
}
76-
7766
replaceCells(from: number, to: number, cells: vscode.NotebookCellData[]): void {
7867
this._throwIfFinalized();
79-
8068
this._collectedEdits.push({
8169
editType: CellEditType.Replace,
8270
index: from,
@@ -89,22 +77,6 @@ class NotebookEditorCellEditBuilder implements vscode.NotebookEditorEdit {
8977
})
9078
});
9179
}
92-
93-
insert(index: number, content: string | string[], language: string, type: CellKind, outputs: vscode.CellOutput[], metadata: vscode.NotebookCellMetadata | undefined): void {
94-
this._throwIfFinalized();
95-
this.replaceCells(index, index, [{
96-
language,
97-
outputs,
98-
metadata,
99-
cellKind: type,
100-
source: Array.isArray(content) ? content.join('\n') : content,
101-
}]);
102-
}
103-
104-
delete(index: number): void {
105-
this._throwIfFinalized();
106-
this.replaceCells(index, 1, []);
107-
}
10880
}
10981

11082
export class ExtHostNotebookEditor extends Disposable implements vscode.NotebookEditor {

0 commit comments

Comments
 (0)