Skip to content

Commit 1895178

Browse files
authored
Finalize notebookWorkspaceEdit api (microsoft#159613)
Fixes microsoft#155245
1 parent ffc2374 commit 1895178

File tree

5 files changed

+68
-90
lines changed

5 files changed

+68
-90
lines changed

extensions/ipynb/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"vscode": "^1.57.0"
1010
},
1111
"enabledApiProposals": [
12-
"notebookWorkspaceEdit",
1312
"documentPaste"
1413
],
1514
"activationEvents": [

extensions/ipynb/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"include": [
1010
"src/**/*",
1111
"../../src/vscode-dts/vscode.d.ts",
12-
"../../src/vscode-dts/vscode.proposed.notebookWorkspaceEdit.d.ts",
1312
"../../src/vscode-dts/vscode.proposed.documentPaste.d.ts"
1413
]
1514
}

src/vs/workbench/services/extensions/common/extensionsApiProposals.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export const allApiProposals = Object.freeze({
4747
notebookLiveShare: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookLiveShare.d.ts',
4848
notebookMessaging: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookMessaging.d.ts',
4949
notebookMime: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookMime.d.ts',
50-
notebookWorkspaceEdit: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookWorkspaceEdit.d.ts',
5150
portsAttributes: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.portsAttributes.d.ts',
5251
quickPickSortByLabel: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.quickPickSortByLabel.d.ts',
5352
resolvers: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.resolvers.d.ts',

src/vscode-dts/vscode.d.ts

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3426,6 +3426,72 @@ declare module 'vscode' {
34263426
constructor(range: Range, newText: string);
34273427
}
34283428

3429+
/**
3430+
* A notebook edit represents edits that should be applied to the contents of a notebook.
3431+
*/
3432+
export class NotebookEdit {
3433+
3434+
/**
3435+
* Utility to create a edit that replaces cells in a notebook.
3436+
*
3437+
* @param range The range of cells to replace
3438+
* @param newCells The new notebook cells.
3439+
*/
3440+
static replaceCells(range: NotebookRange, newCells: NotebookCellData[]): NotebookEdit;
3441+
3442+
/**
3443+
* Utility to create an edit that replaces cells in a notebook.
3444+
*
3445+
* @param index The index to insert cells at.
3446+
* @param newCells The new notebook cells.
3447+
*/
3448+
static insertCells(index: number, newCells: NotebookCellData[]): NotebookEdit;
3449+
3450+
/**
3451+
* Utility to create an edit that deletes cells in a notebook.
3452+
*
3453+
* @param range The range of cells to delete.
3454+
*/
3455+
static deleteCells(range: NotebookRange): NotebookEdit;
3456+
3457+
/**
3458+
* Utility to create an edit that update a cell's metadata.
3459+
*
3460+
* @param index The index of the cell to update.
3461+
* @param newCellMetadata The new metadata for the cell.
3462+
*/
3463+
static updateCellMetadata(index: number, newCellMetadata: { [key: string]: any }): NotebookEdit;
3464+
3465+
/**
3466+
* Utility to create an edit that updates the notebook's metadata.
3467+
*
3468+
* @param newNotebookMetadata The new metadata for the notebook.
3469+
*/
3470+
static updateNotebookMetadata(newNotebookMetadata: { [key: string]: any }): NotebookEdit;
3471+
3472+
/**
3473+
* Range of the cells being edited. May be empty.
3474+
*/
3475+
range: NotebookRange;
3476+
3477+
/**
3478+
* New cells being inserted. May be empty.
3479+
*/
3480+
newCells: NotebookCellData[];
3481+
3482+
/**
3483+
* Optional new metadata for the cells.
3484+
*/
3485+
newCellMetadata?: { [key: string]: any };
3486+
3487+
/**
3488+
* Optional new metadata for the notebook.
3489+
*/
3490+
newNotebookMetadata?: { [key: string]: any };
3491+
3492+
constructor(range: NotebookRange, newCells: NotebookCellData[]);
3493+
}
3494+
34293495
/**
34303496
* Additional data for entries of a workspace edit. Supports to label entries and marks entries
34313497
* as needing confirmation by the user. The editor groups edits with equal labels into tree nodes,
@@ -3508,9 +3574,9 @@ declare module 'vscode' {
35083574
* Set (and replace) text edits for a resource.
35093575
*
35103576
* @param uri A resource identifier.
3511-
* @param edits An array of text edits.
3577+
* @param edits An array of edits.
35123578
*/
3513-
set(uri: Uri, edits: TextEdit[]): void;
3579+
set(uri: Uri, edits: TextEdit[] | NotebookEdit[]): void;
35143580

35153581
/**
35163582
* Get the text edits for a resource.

src/vscode-dts/vscode.proposed.notebookWorkspaceEdit.d.ts

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)