Fix trimming on a buffer with 0 scrollback

Unfortunately this removed the padding idea from CircularList as it
would only work when the list is not full.
This commit is contained in:
Daniel Imms
2017-08-06 18:56:37 -07:00
parent a57f55dcbf
commit e7ee3ec63c
4 changed files with 24 additions and 56 deletions
-25
View File
@@ -9,9 +9,6 @@ class TestCircularList<T> extends CircularList<T> {
public get array(): T[] { return this._array; }
}
const MAX_LENGTH_PADDING = 40;
const MAX_LENGTH_SHRINK_REBUILD_THRESHOLD = 120;
describe('CircularList', () => {
describe('push', () => {
it('should push values onto the array', () => {
@@ -75,28 +72,6 @@ describe('CircularList', () => {
list.maxLength = 4;
assert.equal(list.maxLength, 4);
});
it('should resize the backing array\'s size only when it increases beyond the allocated padding', () => {
const initSize = 200;
const list = new TestCircularList<string>(initSize);
const expectedBackingMaxLength = initSize + MAX_LENGTH_PADDING;
assert.equal(list.array.length, expectedBackingMaxLength);
list.maxLength = expectedBackingMaxLength;
assert.equal(list.array.length, expectedBackingMaxLength);
list.maxLength = expectedBackingMaxLength + 1;
assert.equal(list.array.length, expectedBackingMaxLength + 1 + MAX_LENGTH_PADDING);
});
it('should resize the backing array\'s size only when it reduces beyond the shrink threshold', () => {
const initSize = 200;
const list = new TestCircularList<string>(initSize);
const expectedThresholdMaxLength = initSize + MAX_LENGTH_PADDING - MAX_LENGTH_SHRINK_REBUILD_THRESHOLD;
assert.equal(list.array.length, initSize + MAX_LENGTH_PADDING);
list.maxLength = expectedThresholdMaxLength;
assert.equal(list.array.length, initSize + MAX_LENGTH_PADDING);
list.maxLength = expectedThresholdMaxLength - 1;
assert.equal(list.array.length, expectedThresholdMaxLength - 1 + MAX_LENGTH_PADDING);
});
});
describe('length', () => {