- itemsRemoved = super.splice(start, deleteCount);
- // FIXME: that makes the items insert not in place
- this.push(...items);
+ itemsRemoved = super.splice(start, deleteCount, ...items);
+ if (this.length > this.size) {
+ const itemsOverflowing = super.splice(0, this.length - this.size);
+ itemsRemoved = new CircularArray<T>(
+ itemsRemoved.length + itemsOverflowing.length,
+ ...itemsRemoved,
+ ...itemsOverflowing,
+ );
+ }