MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / lineOffsets

Method lineOffsets

src/common/debug.ts:21–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19 }
20
21 get lineOffsets(): number[] {
22 if (this._lineOffsets == null) {
23 const offsets: number[] = [];
24 const text = this.source;
25 let isLineStart = true;
26 let i = 0;
27 while (i < text.length) {
28 if (isLineStart) {
29 offsets.push(i);
30 isLineStart = false;
31 }
32 const ch = text.charCodeAt(i);
33 isLineStart = ch === 13 || ch === 10 || ch === 0x2028 || ch === 0x2029;
34 if (ch === 13 && i + 1 < text.length && text.charCodeAt(i + 1) === 10) {
35 i++;
36 }
37 i++;
38 }
39 if (isLineStart && text.length > 0) offsets.push(text.length);
40 this._lineOffsets = offsets;
41 }
42 return this._lineOffsets;
43 }
44
45 getLinecol(offset: number): [line: number, col: number] {
46 offset = Math.max(Math.min(offset, this.source.length), 0);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected