Fix issue with the git log

The old code was assuming that the buffer was not going to change, this is not
true with the current impl though where the list is shifted and ybase and ydisp
need to be compensated for that.
This commit is contained in:
Daniel Imms
2016-12-22 02:02:05 -08:00
parent 4bc679b0b3
commit 3b35d12e60
2 changed files with 47 additions and 10 deletions
+11
View File
@@ -84,12 +84,16 @@ export class CircularList<T> {
this._array[this._getCyclicIndex(this._length)] = value;
if (this._length === this.maxLength) {
this._startIndex++;
if (this._startIndex === this.maxLength) {
this._startIndex = 0;
}
} else {
this._length++;
}
}
public pop(): T {
// TODO: This isn't popping from the array, only returning
return this._array[this._getCyclicIndex(this._length-- - 1)];
}
@@ -118,6 +122,13 @@ export class CircularList<T> {
}
}
public trimStart(count: number): void {
// TODO: Error handling
// TODO: Testing (if we need this)
this._startIndex += count;
this._length--;
}
private _getCyclicIndex(index: number): number {
return (this._startIndex + index) % this.maxLength;
}