in packages/selector/src/text/code-point-seeker.ts [89:121]
private _readOrSeekToChunk(
read: true,
target: TChunk,
offset?: number,
): string[];
private _readOrSeekToChunk(
read: false,
target: TChunk,
offset?: number,
): void;
private _readOrSeekToChunk(read: boolean, target: TChunk, offset = 0) {
const oldRawPosition = this.raw.position;
let s = this.raw.readToChunk(target, offset);
const movedForward = this.raw.position >= oldRawPosition;
if (movedForward && endsWithinCharacter(s)) {
this.raw.seekBy(-1);
s = s.slice(0, -1);
} else if (!movedForward && startsWithinCharacter(s)) {
this.raw.seekBy(1);
s = s.slice(1);
}
const result = [...s];
this.position = movedForward
? this.position + result.length
: this.position - result.length;
if (read) return result;
}