fix #121100. PausableEmitter

This commit is contained in:
rebornix
2021-08-04 11:59:07 -07:00
parent 424e5f8de8
commit 369afa6562
4 changed files with 179 additions and 188 deletions

View File

@@ -623,56 +623,6 @@ suite('Notebook API tests', function () {
});
});
test('notebook workspace edit and undo redo', async function () {
const notebook = await openRandomNotebookDocument();
const editor = await vscode.window.showNotebookDocument(notebook);
assert.strictEqual(vscode.window.activeNotebookEditor === editor, true, 'notebook first');
assert.strictEqual(getFocusedCell(editor)?.document.getText(), 'test');
assert.strictEqual(getFocusedCell(editor)?.document.languageId, 'typescript');
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
assert.strictEqual(getFocusedCell(editor)?.document.getText(), '');
await vscode.commands.executeCommand('notebook.cell.insertCodeCellAbove');
const activeCell = getFocusedCell(editor);
assert.notStrictEqual(getFocusedCell(editor), undefined);
assert.strictEqual(activeCell!.document.getText(), '');
assert.strictEqual(editor.document.cellCount, 4);
assert.strictEqual(editor.document.getCells().indexOf(activeCell!), 1);
{
// modify the second cell, delete it
const edit = new vscode.WorkspaceEdit();
edit.insert(getFocusedCell(editor)!.document.uri, new vscode.Position(0, 0), 'var abc = 0;');
await vscode.workspace.applyEdit(edit);
}
{
const focusedCell = getFocusedCell(editor);
assert.strictEqual(focusedCell !== undefined, true);
// delete focused cell
const edit = new vscode.WorkspaceEdit();
edit.replaceNotebookCells(focusedCell!.notebook.uri, new vscode.NotebookRange(focusedCell!.index, focusedCell!.index + 1), []);
await vscode.workspace.applyEdit(edit);
}
assert.strictEqual(editor.document.cellCount, 3);
assert.strictEqual(editor.document.getCells().indexOf(getFocusedCell(editor)!), 1);
// undo should bring back the deleted cell, and revert to previous content and selection
await vscode.commands.executeCommand('undo');
assert.strictEqual(editor.document.cellCount, 4);
assert.strictEqual(editor.document.getCells().indexOf(getFocusedCell(editor)!), 1);
assert.strictEqual(getFocusedCell(editor)?.document.getText(), 'var abc = 0;');
// redo
// await vscode.commands.executeCommand('notebook.redo');
// assert.strictEqual(vscode.window.activeNotebookEditor!.document.cellCount, 2);
// assert.strictEqual(vscode.window.activeNotebookEditor!.document.getCells().indexOf(getFocusedCell(vscode.window.activeNotebookEditor)!), 1);
// assert.strictEqual(vscode.window.activeNotebookEditor?.selection?.document.getText(), 'test');
});
test('multiple tabs: dirty + clean', async function () {
const notebook = await openRandomNotebookDocument();
await vscode.window.showNotebookDocument(notebook);