@@ -153,7 +153,7 @@ interface RangeMatchScopeBucket {
153153}
154154
155155function widenScopeBucket ( bucket : RangeMatchScopeBucket , end : number ) : void {
156- if ( Number . isFinite ( end ) ) bucket . maxEnd = Math . max ( bucket . maxEnd , end )
156+ if ( ! Number . isNaN ( end ) ) bucket . maxEnd = Math . max ( bucket . maxEnd , end )
157157}
158158
159159/**
@@ -190,11 +190,11 @@ function widenScopeBucket(bucket: RangeMatchScopeBucket, end: number): void {
190190 * can still end further right than the one it evicts. Leaving `maxEnd` stale
191191 * there let the short-circuit skip genuine overlaps and leak duplicates.
192192 *
193- * Only finite ends widen it . `Math.max` with a non-finite end would pin
194- * `maxEnd` at ` NaN`, and since every comparison against `NaN` is false that
195- * would silently switch dedupe off for the rest of the scope. A non-finite
196- * range cannot overlap anything anyway - `rangesOverlap` is false for it - so
197- * skipping the widening matches what the unbucketed scan did .
193+ * Only `NaN` ends are ignored . `Math.max` with `NaN` would pin `maxEnd` at
194+ * `NaN`, and since every comparison against `NaN` is false that would silently
195+ * switch dedupe off for the rest of the scope. A `NaN`-ended range cannot
196+ * overlap anything anyway, while positive infinity is an unbounded end that
197+ * can overlap later ranges and therefore must widen the high-water mark .
198198 */
199199export function dedupeOverlappingWorkflowSearchMatches < T extends WorkflowSearchMatch > (
200200 matches : T [ ]
@@ -226,7 +226,7 @@ export function dedupeOverlappingWorkflowSearchMatches<T extends WorkflowSearchM
226226 } else {
227227 bucketsByScopeKey . set ( scopeKey , {
228228 indices : [ deduped . length ] ,
229- maxEnd : Number . isFinite ( matchRange . end ) ? matchRange . end : Number . NEGATIVE_INFINITY ,
229+ maxEnd : Number . isNaN ( matchRange . end ) ? Number . NEGATIVE_INFINITY : matchRange . end ,
230230 } )
231231 }
232232 }
0 commit comments