diff --git a/src/json-crdt-extensions/peritext/overlay/Overlay.ts b/src/json-crdt-extensions/peritext/overlay/Overlay.ts index 54be9c4963..ecd0d98c0e 100644 --- a/src/json-crdt-extensions/peritext/overlay/Overlay.ts +++ b/src/json-crdt-extensions/peritext/overlay/Overlay.ts @@ -165,8 +165,8 @@ export class Overlay implements Printable, Stateful { }) as Chunk; } - public points0(after: undefined | OverlayPoint): UndefIterator> { - let curr = after ? next(after) : this.first(); + public points0(after: undefined | OverlayPoint, inclusive?: boolean): UndefIterator> { + let curr = after ? (inclusive ? after : next(after)) : this.first(); return () => { const ret = curr; if (curr) curr = next(curr); @@ -174,8 +174,8 @@ export class Overlay implements Printable, Stateful { }; } - public points(after?: undefined | OverlayPoint): IterableIterator> { - return new UndefEndIter(this.points0(after)); + public points(after?: undefined | OverlayPoint, inclusive?: boolean): IterableIterator> { + return new UndefEndIter(this.points0(after, inclusive)); } public markers0(after: undefined | MarkerOverlayPoint): UndefIterator> { @@ -325,7 +325,7 @@ export class Overlay implements Printable, Stateful { public stat(range: Range, endOnMarker = 10): [complete: Set, partial: Set, markerCount: number] { const {start, end} = range; const after = this.getOrNextLower(start); // TODO: this should consider only non-marker points. - const iterator = this.points0(after ? prev(after) : void 0); + const iterator = this.points0(after, true); const partial = new Set(); let complete: Set = new Set(); let isFirst = true; diff --git a/src/json-crdt-extensions/peritext/overlay/__tests__/Overlay.stat.spec.ts b/src/json-crdt-extensions/peritext/overlay/__tests__/Overlay.stat.spec.ts index 194197bb62..a4745f0c12 100644 --- a/src/json-crdt-extensions/peritext/overlay/__tests__/Overlay.stat.spec.ts +++ b/src/json-crdt-extensions/peritext/overlay/__tests__/Overlay.stat.spec.ts @@ -40,6 +40,14 @@ const statTestSuite = (setup: () => Kit) => { const stats = peritext.overlay.stat(editor.cursor); expect(stats).toEqual([new Set(['bold']), new Set(), 0]); }); + + test.todo('multiple interleaved styles'); + test.todo('erasures work'); + test.todo('handle stack slices'); + test.todo('Edge case: text REL end'); + test.todo('Edge case: text ABS end'); + test.todo('Edge case: marker overlay point is the first point'); + test.todo('handle markers in between: can terminate early once first marker encountered'); }; describe('.stat()', () => {