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

Method getLinecol

src/common/debug.ts:45–58  ·  view source on GitHub ↗
(offset: number)

Source from the content-addressed store, hash-verified

43 }
44
45 getLinecol(offset: number): [line: number, col: number] {
46 offset = Math.max(Math.min(offset, this.source.length), 0);
47
48 const lineOffsets = this.lineOffsets;
49 let low = 0;
50 let high = lineOffsets.length;
51 if (high === 0) return [1, offset + 1];
52 while (low < high) {
53 const mid = Math.floor((low + high) / 2);
54 if (lineOffsets[mid] > offset) high = mid;
55 else low = mid + 1;
56 }
57 return [low, offset - lineOffsets[low - 1] + 1];
58 }
59
60 signalOrigin(offset: number): SignalOrigin {
61 const [line, column] = this.getLinecol(offset);

Callers 2

signalOriginMethod · 0.95
parse-cortex.tsFile · 0.80

Calls 1

floorMethod · 0.45

Tested by

no test coverage detected