Enable setTextDocumentLanguage (#119429)

Change cell TextModel handling, fix #117936
This commit is contained in:
Rob Lourens
2021-03-31 17:04:10 -07:00
committed by GitHub
parent 0631bbc801
commit b41213c573
9 changed files with 125 additions and 54 deletions

View File

@@ -1025,6 +1025,27 @@ suite('Notebook API tests', function () {
await saveFileAndCloseAll(resource);
});
test('change cell language when notebook editor is not open', async function () {
const resource = await createRandomFile('', undefined, '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
const firstCell = vscode.window.activeNotebookEditor!.document.cellAt(0);
const cellUri = firstCell.document.uri;
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
let cellDoc = await vscode.workspace.openTextDocument(cellUri);
cellDoc = await vscode.languages.setTextDocumentLanguage(cellDoc, 'css');
assert.strictEqual(cellDoc.languageId, 'css');
});
test('change cell language when notebook editor is open', async function () {
const resource = await createRandomFile('', undefined, '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
const firstCell = vscode.window.activeNotebookEditor!.document.cellAt(0);
const cellDoc = await vscode.languages.setTextDocumentLanguage(firstCell.document, 'css');
assert.strictEqual(cellDoc.languageId, 'css');
});
test('multiple tabs: dirty + clean', async function () {
const resource = await createRandomFile('', undefined, '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');