mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 01:29:04 +01:00
Remove notebook content provider save and backup functionality (#160581)
For #147248 When stepping through the liveshare code, we figured out they do not appear to be using `save`, `saveAs`, or `backup` (they return empty results for these) This PR removes this part of the proposal so we can track just the parts of the api that they are using
This commit is contained in:
@@ -115,18 +115,6 @@ const apiTestContentProvider: vscode.NotebookContentProvider = {
|
||||
};
|
||||
return dto;
|
||||
},
|
||||
saveNotebook: async (_document: vscode.NotebookDocument, _cancellation: vscode.CancellationToken) => {
|
||||
return;
|
||||
},
|
||||
saveNotebookAs: async (_targetResource: vscode.Uri, _document: vscode.NotebookDocument, _cancellation: vscode.CancellationToken) => {
|
||||
return;
|
||||
},
|
||||
backupNotebook: async (_document: vscode.NotebookDocument, _context: vscode.NotebookDocumentBackupContext, _cancellation: vscode.CancellationToken) => {
|
||||
return {
|
||||
id: '1',
|
||||
delete: () => { }
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
(vscode.env.uiKind === vscode.UIKind.Web ? suite.skip : suite)('Notebook API tests', function () {
|
||||
@@ -244,7 +232,8 @@ const apiTestContentProvider: vscode.NotebookContentProvider = {
|
||||
await closeAllEditors();
|
||||
});
|
||||
|
||||
test('#115855 onDidSaveNotebookDocument', async function () {
|
||||
// TODO: Skipped due to notebook content provider removal
|
||||
test.skip('#115855 onDidSaveNotebookDocument', async function () {
|
||||
const resource = await createRandomNotebookFile();
|
||||
const notebook = await vscode.workspace.openNotebookDocument(resource);
|
||||
|
||||
|
||||
@@ -26,15 +26,6 @@ suite('Notebook Document', function () {
|
||||
[new vscode.NotebookCellData(vscode.NotebookCellKind.Code, uri.toString(), 'javascript')],
|
||||
);
|
||||
}
|
||||
async saveNotebook(_document: vscode.NotebookDocument, _cancellation: vscode.CancellationToken) {
|
||||
//
|
||||
}
|
||||
async saveNotebookAs(_targetResource: vscode.Uri, _document: vscode.NotebookDocument, _cancellation: vscode.CancellationToken) {
|
||||
//
|
||||
}
|
||||
async backupNotebook(_document: vscode.NotebookDocument, _context: vscode.NotebookDocumentBackupContext, _cancellation: vscode.CancellationToken) {
|
||||
return { id: '', delete() { } };
|
||||
}
|
||||
};
|
||||
|
||||
const disposables: vscode.Disposable[] = [];
|
||||
@@ -329,40 +320,6 @@ suite('Notebook Document', function () {
|
||||
assert.ok(document.metadata.custom.extraNotebookMetadata, `Test metadata not found`);
|
||||
});
|
||||
|
||||
test('document save API', async function () {
|
||||
const uri = await utils.createRandomFile(undefined, undefined, '.nbdtest');
|
||||
const notebook = await vscode.workspace.openNotebookDocument(uri);
|
||||
|
||||
assert.strictEqual(notebook.uri.toString(), uri.toString());
|
||||
assert.strictEqual(notebook.isDirty, false);
|
||||
assert.strictEqual(notebook.isUntitled, false);
|
||||
assert.strictEqual(notebook.cellCount, 1);
|
||||
assert.strictEqual(notebook.notebookType, 'notebook.nbdtest');
|
||||
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
edit.set(notebook.uri, [vscode.NotebookEdit.replaceCells(new vscode.NotebookRange(0, 0), [{
|
||||
kind: vscode.NotebookCellKind.Markup,
|
||||
languageId: 'markdown',
|
||||
metadata: undefined,
|
||||
outputs: [],
|
||||
value: 'new_markdown'
|
||||
}, {
|
||||
kind: vscode.NotebookCellKind.Code,
|
||||
languageId: 'fooLang',
|
||||
metadata: undefined,
|
||||
outputs: [],
|
||||
value: 'new_code'
|
||||
}])]);
|
||||
|
||||
const success = await vscode.workspace.applyEdit(edit);
|
||||
assert.strictEqual(success, true);
|
||||
assert.strictEqual(notebook.isDirty, true);
|
||||
|
||||
await notebook.save();
|
||||
assert.strictEqual(notebook.isDirty, false);
|
||||
});
|
||||
|
||||
|
||||
test('setTextDocumentLanguage for notebook cells', async function () {
|
||||
|
||||
const uri = await utils.createRandomFile(undefined, undefined, '.nbdtest');
|
||||
@@ -395,21 +352,6 @@ suite('Notebook Document', function () {
|
||||
assert.strictEqual(cellDoc.languageId, 'css');
|
||||
});
|
||||
|
||||
test('dirty state - complex', async function () {
|
||||
const resource = await utils.createRandomFile(undefined, undefined, '.nbdtest');
|
||||
const document = await vscode.workspace.openNotebookDocument(resource);
|
||||
assert.strictEqual(document.isDirty, false);
|
||||
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
edit.set(document.uri, [vscode.NotebookEdit.replaceCells(new vscode.NotebookRange(0, document.cellCount), [])]);
|
||||
assert.ok(await vscode.workspace.applyEdit(edit));
|
||||
|
||||
assert.strictEqual(document.isDirty, true);
|
||||
|
||||
await document.save();
|
||||
assert.strictEqual(document.isDirty, false);
|
||||
});
|
||||
|
||||
test('dirty state - serializer', async function () {
|
||||
const resource = await utils.createRandomFile(undefined, undefined, '.nbdserializer');
|
||||
const document = await vscode.workspace.openNotebookDocument(resource);
|
||||
|
||||
@@ -124,18 +124,6 @@ const apiTestContentProvider: vscode.NotebookContentProvider = {
|
||||
]
|
||||
};
|
||||
return dto;
|
||||
},
|
||||
saveNotebook: async (_document: vscode.NotebookDocument, _cancellation: vscode.CancellationToken) => {
|
||||
return;
|
||||
},
|
||||
saveNotebookAs: async (_targetResource: vscode.Uri, _document: vscode.NotebookDocument, _cancellation: vscode.CancellationToken) => {
|
||||
return;
|
||||
},
|
||||
backupNotebook: async (_document: vscode.NotebookDocument, _context: vscode.NotebookDocumentBackupContext, _cancellation: vscode.CancellationToken) => {
|
||||
return {
|
||||
id: '1',
|
||||
delete: () => { }
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user