add codePointAt and don't normalize

This commit is contained in:
Yura Dupyn 2026-04-06 19:12:36 +02:00
parent 7757394fab
commit 345f69fd1c

View file

@ -23,7 +23,9 @@ export class SourceText {
readonly lineStarts: CodePointIndex[];
constructor(rawSource: string) {
const source = rawSource.normalize('NFC');
// TODO: This shouldn't really be a concern of the library.
// const source = rawSource.normalize('NFC');
const source = rawSource;
this.source = source;
this.chars = [];
@ -57,6 +59,10 @@ export class SourceText {
}
}
codePointAt(index: CodePointIndex): CodePoint {
return this.chars[index].char;
}
get length(): number {
return this.chars.length;
}
@ -196,6 +202,10 @@ export class SourceRegion {
public readonly span: Span
) {}
codePointAt(index: CodePointIndex): CodePoint {
return this.source.codePointAt(index);
}
get length(): number {
return this.span.end.index - this.span.start.index;
}