diff --git a/packages/compiler/src/syntax/span.ts b/packages/compiler/src/syntax/span.ts index 6177ec3..96c7546 100644 --- a/packages/compiler/src/syntax/span.ts +++ b/packages/compiler/src/syntax/span.ts @@ -33,17 +33,17 @@ export class SpanIndex { let lo = 0; let hi = this.index.length; - // console.log(`\nsearching for ${target}`); + // console.log(`\nsearching for ${pos}`); while (true) { if (lo === hi) { if (lo === 0) return null; const e = this.index[lo - 1]; if (e[0] > pos) throw new Error("INTERNAL ERROR: bad binary search (1)"); if (this.index[lo]?.[0] <= pos) throw new Error("INTERNAL ERROR: bad binary search (2)"); - // console.log(`found ${JSON.stringify(e)}, ${JSON.stringify(items[lo] ?? null)}`); + // console.log(`found ${JSON.stringify(e)}, ${JSON.stringify(this.index[lo] ?? null)}`); const r = new SpanResult(pos, e[0]); e[1].forEach(([end, item]) => { - if (pos < end) { + if (pos <= end) { r.items.push({ end, item }); } }); @@ -53,7 +53,7 @@ export class SpanIndex { const mid = (lo + hi) >> 1; const e = this.index[mid]; - // console.log(`${target} lo ${lo} hi ${hi} mid ${mid} probe ${JSON.stringify([e[0], e[1].target])}`); + // console.log(`${pos} lo ${lo} hi ${hi} mid ${mid} probe ${JSON.stringify(e)}`); if (e[0] <= pos) { lo = mid + 1;