Add max size setting for Rich Text undo history in notebooks. (#15793)

This commit is contained in:
Cory Rivera
2021-06-18 16:04:45 -07:00
committed by GitHub
parent 2eab870ca2
commit d92c1d5ca8
3 changed files with 48 additions and 4 deletions

View File

@@ -264,7 +264,8 @@ suite('notebookUtils', function (): void {
});
test('EditStack test', async function (): Promise<void> {
let stack = new RichTextEditStack();
let maxStackSize = 200;
let stack = new RichTextEditStack(maxStackSize);
assert.strictEqual(stack.count, 0);
stack.push('1');
@@ -290,5 +291,21 @@ suite('notebookUtils', function (): void {
topElement = stack.pop();
assert.strictEqual(topElement, undefined);
assert.strictEqual(stack.peek(), undefined);
// Check max stack size
stack.clear();
for (let i = 0; i < maxStackSize; i++) {
stack.push('a');
}
stack.push('b');
assert.strictEqual(stack.count, maxStackSize);
assert.strictEqual(stack.peek(), 'b');
// update max stack size and add new element
maxStackSize = 20;
stack.maxStackSize = maxStackSize;
stack.push('c');
assert.strictEqual(stack.count, maxStackSize);
assert.strictEqual(stack.peek(), 'c');
});
});