mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 09:38:38 +01:00
move file'ish things into workspace namespace
This commit is contained in:
@@ -48,22 +48,22 @@ suite('Notebook Document', function () {
|
||||
});
|
||||
|
||||
suiteSetup(function () {
|
||||
disposables.push(vscode.notebook.registerNotebookContentProvider('notebook.nbdtest', complexContentProvider));
|
||||
disposables.push(vscode.notebook.registerNotebookSerializer('notebook.nbdserializer', simpleContentProvider));
|
||||
disposables.push(vscode.workspace.registerNotebookContentProvider('notebook.nbdtest', complexContentProvider));
|
||||
disposables.push(vscode.workspace.registerNotebookSerializer('notebook.nbdserializer', simpleContentProvider));
|
||||
});
|
||||
|
||||
test('cannot register sample provider multiple times', function () {
|
||||
assert.throws(() => {
|
||||
vscode.notebook.registerNotebookContentProvider('notebook.nbdtest', complexContentProvider);
|
||||
vscode.workspace.registerNotebookContentProvider('notebook.nbdtest', complexContentProvider);
|
||||
});
|
||||
// assert.throws(() => {
|
||||
// vscode.notebook.registerNotebookSerializer('notebook.nbdserializer', simpleContentProvider);
|
||||
// vscode.workspace.registerNotebookSerializer('notebook.nbdserializer', simpleContentProvider);
|
||||
// });
|
||||
});
|
||||
|
||||
test('cannot open unknown types', async function () {
|
||||
try {
|
||||
await vscode.notebook.openNotebookDocument(vscode.Uri.parse('some:///thing.notTypeKnown'));
|
||||
await vscode.workspace.openNotebookDocument(vscode.Uri.parse('some:///thing.notTypeKnown'));
|
||||
assert.ok(false);
|
||||
} catch {
|
||||
assert.ok(true);
|
||||
@@ -72,7 +72,7 @@ suite('Notebook Document', function () {
|
||||
|
||||
test('document basics', async function () {
|
||||
const uri = await utils.createRandomFile(undefined, undefined, '.nbdtest');
|
||||
const notebook = await vscode.notebook.openNotebookDocument(uri);
|
||||
const notebook = await vscode.workspace.openNotebookDocument(uri);
|
||||
|
||||
assert.strictEqual(notebook.uri.toString(), uri.toString());
|
||||
assert.strictEqual(notebook.isDirty, false);
|
||||
@@ -92,7 +92,7 @@ suite('Notebook Document', function () {
|
||||
// ignore other open events
|
||||
return;
|
||||
}
|
||||
const notebook = vscode.notebook.notebookDocuments.find(notebook => {
|
||||
const notebook = vscode.workspace.notebookDocuments.find(notebook => {
|
||||
const cell = notebook.getCells().find(cell => cell.document === doc);
|
||||
return Boolean(cell);
|
||||
});
|
||||
@@ -108,7 +108,7 @@ suite('Notebook Document', function () {
|
||||
}, 15000);
|
||||
});
|
||||
|
||||
await vscode.notebook.openNotebookDocument(uri);
|
||||
await vscode.workspace.openNotebookDocument(uri);
|
||||
await p;
|
||||
assert.strictEqual(didHappen, true);
|
||||
});
|
||||
@@ -116,7 +116,7 @@ suite('Notebook Document', function () {
|
||||
test('notebook open/close, all cell-documents are ready', async function () {
|
||||
const uri = await utils.createRandomFile(undefined, undefined, '.nbdtest');
|
||||
|
||||
const p = utils.asPromise(vscode.notebook.onDidOpenNotebookDocument).then(notebook => {
|
||||
const p = utils.asPromise(vscode.workspace.onDidOpenNotebookDocument).then(notebook => {
|
||||
for (let i = 0; i < notebook.cellCount; i++) {
|
||||
let cell = notebook.cellAt(i);
|
||||
|
||||
@@ -130,12 +130,12 @@ suite('Notebook Document', function () {
|
||||
}
|
||||
});
|
||||
|
||||
await vscode.notebook.openNotebookDocument(uri);
|
||||
await vscode.workspace.openNotebookDocument(uri);
|
||||
await p;
|
||||
});
|
||||
|
||||
test('open untitled notebook', async function () {
|
||||
const nb = await vscode.notebook.openNotebookDocument('notebook.nbdserializer');
|
||||
const nb = await vscode.workspace.openNotebookDocument('notebook.nbdserializer');
|
||||
assert.strictEqual(nb.isUntitled, true);
|
||||
assert.strictEqual(nb.isClosed, false);
|
||||
assert.strictEqual(nb.uri.scheme, 'untitled');
|
||||
@@ -143,7 +143,7 @@ suite('Notebook Document', function () {
|
||||
});
|
||||
|
||||
test('open untitled with data', async function () {
|
||||
const nb = await vscode.notebook.openNotebookDocument(
|
||||
const nb = await vscode.workspace.openNotebookDocument(
|
||||
'notebook.nbdserializer',
|
||||
new vscode.NotebookData([
|
||||
new vscode.NotebookCellData(vscode.NotebookCellKind.Code, 'console.log()', 'javascript'),
|
||||
@@ -162,7 +162,7 @@ suite('Notebook Document', function () {
|
||||
test('workspace edit API (replaceCells)', async function () {
|
||||
const uri = await utils.createRandomFile(undefined, undefined, '.nbdtest');
|
||||
|
||||
const document = await vscode.notebook.openNotebookDocument(uri);
|
||||
const document = await vscode.workspace.openNotebookDocument(uri);
|
||||
assert.strictEqual(document.cellCount, 1);
|
||||
|
||||
// inserting two new cells
|
||||
@@ -237,7 +237,7 @@ suite('Notebook Document', function () {
|
||||
|
||||
test('workspace edit API (replaceCells, event)', async function () {
|
||||
const uri = await utils.createRandomFile(undefined, undefined, '.nbdtest');
|
||||
const document = await vscode.notebook.openNotebookDocument(uri);
|
||||
const document = await vscode.workspace.openNotebookDocument(uri);
|
||||
assert.strictEqual(document.cellCount, 1);
|
||||
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
@@ -279,7 +279,7 @@ suite('Notebook Document', function () {
|
||||
|
||||
test('document save API', async function () {
|
||||
const uri = await utils.createRandomFile(undefined, undefined, '.nbdtest');
|
||||
const notebook = await vscode.notebook.openNotebookDocument(uri);
|
||||
const notebook = await vscode.workspace.openNotebookDocument(uri);
|
||||
|
||||
assert.strictEqual(notebook.uri.toString(), uri.toString());
|
||||
assert.strictEqual(notebook.isDirty, false);
|
||||
@@ -314,7 +314,7 @@ suite('Notebook Document', function () {
|
||||
test('setTextDocumentLanguage for notebook cells', async function () {
|
||||
|
||||
const uri = await utils.createRandomFile(undefined, undefined, '.nbdtest');
|
||||
const notebook = await vscode.notebook.openNotebookDocument(uri);
|
||||
const notebook = await vscode.workspace.openNotebookDocument(uri);
|
||||
const first = notebook.cellAt(0);
|
||||
assert.strictEqual(first.document.languageId, 'javascript');
|
||||
|
||||
@@ -334,7 +334,7 @@ suite('Notebook Document', function () {
|
||||
|
||||
test('setTextDocumentLanguage when notebook editor is not open', async function () {
|
||||
const uri = await utils.createRandomFile('', undefined, '.nbdtest');
|
||||
const notebook = await vscode.notebook.openNotebookDocument(uri);
|
||||
const notebook = await vscode.workspace.openNotebookDocument(uri);
|
||||
const firstCelUri = notebook.cellAt(0).document.uri;
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
|
||||
@@ -345,7 +345,7 @@ suite('Notebook Document', function () {
|
||||
|
||||
test('dirty state - complex', async function () {
|
||||
const resource = await utils.createRandomFile(undefined, undefined, '.nbdtest');
|
||||
const document = await vscode.notebook.openNotebookDocument(resource);
|
||||
const document = await vscode.workspace.openNotebookDocument(resource);
|
||||
assert.strictEqual(document.isDirty, false);
|
||||
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
@@ -360,7 +360,7 @@ suite('Notebook Document', function () {
|
||||
|
||||
test('dirty state - serializer', async function () {
|
||||
const resource = await utils.createRandomFile(undefined, undefined, '.nbdserializer');
|
||||
const document = await vscode.notebook.openNotebookDocument(resource);
|
||||
const document = await vscode.workspace.openNotebookDocument(resource);
|
||||
assert.strictEqual(document.isDirty, false);
|
||||
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
|
||||
@@ -29,19 +29,19 @@ suite('Notebook Editor', function () {
|
||||
utils.disposeAll(disposables);
|
||||
disposables.length = 0;
|
||||
|
||||
for (let doc of vscode.notebook.notebookDocuments) {
|
||||
for (let doc of vscode.workspace.notebookDocuments) {
|
||||
assert.strictEqual(doc.isDirty, false, doc.uri.toString());
|
||||
}
|
||||
});
|
||||
|
||||
suiteSetup(function () {
|
||||
disposables.push(vscode.notebook.registerNotebookSerializer('notebook.nbdtest', contentSerializer));
|
||||
disposables.push(vscode.workspace.registerNotebookSerializer('notebook.nbdtest', contentSerializer));
|
||||
});
|
||||
|
||||
|
||||
test('showNotebookDocment', async function () {
|
||||
|
||||
const p = utils.asPromise(vscode.notebook.onDidOpenNotebookDocument);
|
||||
const p = utils.asPromise(vscode.workspace.onDidOpenNotebookDocument);
|
||||
const uri = await utils.createRandomFile(undefined, undefined, '.nbdtest');
|
||||
|
||||
const editor = await vscode.window.showNotebookDocument(uri);
|
||||
@@ -50,7 +50,7 @@ suite('Notebook Editor', function () {
|
||||
const event = await p;
|
||||
assert.strictEqual(event.uri.toString(), uri.toString());
|
||||
|
||||
const includes = vscode.notebook.notebookDocuments.includes(editor.document);
|
||||
const includes = vscode.workspace.notebookDocuments.includes(editor.document);
|
||||
assert.strictEqual(true, includes);
|
||||
});
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ async function createRandomNotebookFile() {
|
||||
|
||||
async function openRandomNotebookDocument() {
|
||||
const uri = await createRandomNotebookFile();
|
||||
return vscode.notebook.openNotebookDocument(uri);
|
||||
return vscode.workspace.openNotebookDocument(uri);
|
||||
}
|
||||
|
||||
async function saveAllFilesAndCloseAll() {
|
||||
@@ -104,7 +104,7 @@ suite('Notebook API tests', function () {
|
||||
});
|
||||
|
||||
suiteSetup(function () {
|
||||
suiteDisposables.push(vscode.notebook.registerNotebookContentProvider('notebookCoreTest', {
|
||||
suiteDisposables.push(vscode.workspace.registerNotebookContentProvider('notebookCoreTest', {
|
||||
openNotebook: async (resource: vscode.Uri): Promise<vscode.NotebookData> => {
|
||||
if (/.*empty\-.*\.vsctestnb$/.test(resource.path)) {
|
||||
return {
|
||||
@@ -166,7 +166,7 @@ suite('Notebook API tests', function () {
|
||||
|
||||
kernel1 = new Kernel('mainKernel', 'Notebook Primary Test Kernel');
|
||||
|
||||
const listener = vscode.notebook.onDidOpenNotebookDocument(async notebook => {
|
||||
const listener = vscode.workspace.onDidOpenNotebookDocument(async notebook => {
|
||||
if (notebook.notebookType === kernel1.controller.notebookType) {
|
||||
await vscode.commands.executeCommand('notebook.selectKernel', {
|
||||
extension: 'vscode.vscode-api-tests',
|
||||
@@ -204,7 +204,7 @@ suite('Notebook API tests', function () {
|
||||
|
||||
test('shared document in notebook editors', async function () {
|
||||
let counter = 0;
|
||||
testDisposables.push(vscode.notebook.onDidOpenNotebookDocument(() => {
|
||||
testDisposables.push(vscode.workspace.onDidOpenNotebookDocument(() => {
|
||||
counter++;
|
||||
}));
|
||||
|
||||
@@ -1149,7 +1149,7 @@ suite('Notebook API tests', function () {
|
||||
|
||||
test('#115855 onDidSaveNotebookDocument', async function () {
|
||||
const resource = await createRandomNotebookFile();
|
||||
const notebook = await vscode.notebook.openNotebookDocument(resource);
|
||||
const notebook = await vscode.workspace.openNotebookDocument(resource);
|
||||
const editor = await vscode.window.showNotebookDocument(notebook);
|
||||
|
||||
const cellsChangeEvent = asPromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
|
||||
|
||||
@@ -90,13 +90,13 @@ suite('vscode', function () {
|
||||
});
|
||||
|
||||
test('no rpc, createNotebookEditorDecorationType(...)', function () {
|
||||
const item = vscode.notebook.createNotebookEditorDecorationType({ top: {} });
|
||||
const item = vscode.notebooks.createNotebookEditorDecorationType({ top: {} });
|
||||
dispo.push(item);
|
||||
assertNoRpcFromEntry([item, 'NotebookEditorDecorationType']);
|
||||
});
|
||||
|
||||
test('no rpc, createNotebookController(...)', function () {
|
||||
const ctrl = vscode.notebook.createNotebookController('foo', 'bar', '');
|
||||
const ctrl = vscode.notebooks.createNotebookController('foo', 'bar', '');
|
||||
dispo.push(ctrl);
|
||||
assertNoRpcFromEntry([ctrl, 'NotebookController']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user