Skip to content

Commit

Permalink
feat(json-crdt-extensions): 🎸 improve how cursor is displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Apr 30, 2024
1 parent 75e2620 commit ceadbdd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ describe('slices', () => {
expect(point3.layers[1].data()).toStrictEqual({bold: true});
const point4 = next(point3)!;
expect(point4.layers.length).toBe(0);
console.log(peritext + '');
});

test('one char slice should correctly sort overlay points', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/json-crdt-extensions/peritext/slice/Cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ export class Cursor<T = string> extends Range<T> implements Slice<T> {
// ---------------------------------------------------------------- Printable

public toString(tab: string = ''): string {
const text = JSON.stringify(this.text());
const text = this.text();
const focusIcon = this.anchorSide === CursorAnchor.Start ? '.→|' : '|←.';
const main = `${this.constructor.name} ${super.toString(tab + ' ', true)} ${focusIcon}`;
return main + printTree(tab, [() => text]);
return main + (text.length > 32 ? printTree(tab, [() => JSON.stringify(text)]) : '');
}
}

0 comments on commit ceadbdd

Please sign in to comment.