fix(notebook): redo cell creation does not re-select the cell

This commit is contained in:
arnobl
2021-03-28 23:15:28 +02:00
committed by rebornix
parent 2111c11380
commit 1c3c96b4b9
3 changed files with 22 additions and 5 deletions

View File

@@ -308,6 +308,25 @@ suite('Notebook API tests', function () {
assert.strictEqual(count, 0);
});
test('correct cell selection on undo/redo of cell creation', async function () {
const resource = await createRandomFile('', undefined, '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
await vscode.commands.executeCommand('undo');
const selectionUndo = [...vscode.window.activeNotebookEditor!.selections];
await vscode.commands.executeCommand('redo');
const selectionRedo = vscode.window.activeNotebookEditor!.selections;
// On undo, the selected cell must be the upper cell, ie the first one
assert.strictEqual(selectionUndo.length, 1);
assert.strictEqual(selectionUndo[0].start, 0);
assert.strictEqual(selectionUndo[0].end, 1);
// On redo, the selected cell must be the new cell, ie the second one
assert.strictEqual(selectionRedo.length, 1);
assert.strictEqual(selectionRedo[0].start, 1);
assert.strictEqual(selectionRedo[0].end, 2);
});
test('editor editing event 2', async function () {
const resource = await createRandomFile('', undefined, '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');