Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test notebook workspace edit API #107622

Closed
2 tasks done
rebornix opened this issue Sep 28, 2020 · 2 comments
Closed
2 tasks done

Test notebook workspace edit API #107622

rebornix opened this issue Sep 28, 2020 · 2 comments

Comments

@rebornix
Copy link
Member

rebornix commented Sep 28, 2020

Refs: #105283

Complexity: 4

Authors: @jrieken @rebornix

Create Issue


We have made good progress with notebook editing API (including changes to the d.ts and also internal infrastructure). Now changes from UI or extensions will all land in the same code path NotebookTextModel.applyEdits so we want to test how robust the API and the implementation is.

Interface

export interface WorkspaceEdit {
  replaceNotebookMetadata(uri: Uri, value: NotebookDocumentMetadata): void;
  replaceNotebookCells(uri: Uri, start: number, end: number, cells: NotebookCellData[], metadata?: WorkspaceEditEntryMetadata): void;
  replaceNotebookCellOutput(uri: Uri, index: number, outputs: (NotebookCellOutput | CellOutput)[], metadata?: WorkspaceEditEntryMetadata): void;
  replaceNotebookCellMetadata(uri: Uri, index: number, cellMetadata: NotebookCellMetadata, metadata?: WorkspaceEditEntryMetadata): void;
}

To test this set of API:

subscriptions.push(vscode.commands.registerCommand('github-issues.testLockCell', async () => {
	const editor = vscode.notebook.activeNotebookEditor;
	if (!editor) {
		return;
	}

	const selection = editor.selection;
	if (!selection) {
		return;
	}

	const workspaceEdit = new vscode.WorkspaceEdit();
	workspaceEdit.replaceNotebookCellMetadata(editor.document.uri, selection.index, {
		...selection.metadata,
		editable: false
	});

	await vscode.workspace.applyEdit(workspaceEdit);
}));
  • and then run the command in a GitHub issue notebook file

Please test at least following scenarios

@alexr00
Copy link
Member

alexr00 commented Sep 30, 2020

I tested the following:

I used this API to replace and delete cells:
https://github.com/Microsoft/vscode/blob/4482c8794fa5e6b77ae08be69784352b8cde32ea/src/vs/vscode.proposed.d.ts#L1437-L1437

I could not find a way to insert cells.

@alexr00 alexr00 removed their assignment Sep 30, 2020
@rebornix
Copy link
Member Author

@alexr00 to insert a cell you can

workspaceEdit.replaceNotebookCells(editor.document.uri, 0, 0, [
{
  cellKind: vscode.CellKind.Code,
  language: 'github-issues',
  metadata: {},
  outputs: [],
  source: 'test'
}
]);

@lszomoru lszomoru removed their assignment Oct 1, 2020
@lszomoru lszomoru closed this as completed Oct 1, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants