Improve Undo and Redo functionality for notebook Rich Text editors (#15627)

This commit is contained in:
Cory Rivera
2021-06-08 13:24:58 -07:00
committed by GitHub
parent d6d2e7dc08
commit a61462a2c0
2 changed files with 125 additions and 3 deletions

View File

@@ -11,6 +11,7 @@ import { getHostAndPortFromEndpoint, isStream, getProvidersForFileName, asyncFor
import { INotebookService, DEFAULT_NOTEBOOK_FILETYPE, DEFAULT_NOTEBOOK_PROVIDER } from 'sql/workbench/services/notebook/browser/notebookService';
import { NotebookServiceStub } from 'sql/workbench/contrib/notebook/test/stubs';
import { tryMatchCellMagic, extractCellMagicCommandPlusArgs } from 'sql/workbench/services/notebook/browser/utils';
import { RichTextEditStack } from 'sql/workbench/contrib/notebook/browser/cellViews/textCell.component';
suite('notebookUtils', function (): void {
const mockNotebookService = TypeMoq.Mock.ofType<INotebookService>(NotebookServiceStub);
@@ -261,4 +262,33 @@ suite('notebookUtils', function (): void {
result = rewriteUrlUsingRegex(/(https?:\/\/sparkhead.*\/proxy)(.*)/g, html, '1.1.1.1', ':999', '/gateway/default/yarn/proxy');
assert.strictEqual(result, '<a target="_blank" href="https://storage-0-0.storage-0-svc.mssql-cluster.svc.cluster.local:8044/node/containerlogs/container_7/root“>Link</a>', 'Target URL should not have been edited');
});
test('EditStack test', async function (): Promise<void> {
let stack = new RichTextEditStack();
assert.strictEqual(stack.count, 0);
stack.push('1');
stack.push('2');
stack.push('3');
assert.strictEqual(stack.count, 3);
assert.strictEqual(stack.peek(), '3');
let topElement = stack.pop();
assert.strictEqual(topElement, '3');
topElement = stack.pop();
assert.strictEqual(topElement, '2');
stack.push('4');
assert.strictEqual(stack.count, 2);
topElement = stack.pop();
assert.strictEqual(topElement, '4');
stack.clear();
assert.strictEqual(stack.count, 0);
topElement = stack.pop();
assert.strictEqual(topElement, undefined);
assert.strictEqual(stack.peek(), undefined);
});
});