mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 17:23:40 -05:00
Improve Undo and Redo functionality for notebook Rich Text editors (#15627)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user