@@ -63,6 +63,11 @@ export interface RangeComparator<T extends RangeValue> {
63
63
compareRange ( from : number , to : number , activeA : T [ ] , activeB : T [ ] ) : void
64
64
/// Notification for a changed (or inserted, or deleted) point range.
65
65
comparePoint ( from : number , to : number , pointA : T | null , pointB : T | null ) : void
66
+ /// Notification for a changed boundary between ranges. For example,
67
+ /// if the same span is covered by two partial ranges before and one
68
+ /// bigger range after, this is called at the point where the ranges
69
+ /// used to be split.
70
+ boundChange ?( pos : number ) : void
66
71
}
67
72
68
73
/// Methods used when iterating over the spans created by a set of
@@ -827,14 +832,15 @@ function compare<T extends RangeValue>(a: SpanCursor<T>, startA: number,
827
832
let endB = startB + length
828
833
let pos = startB , dPos = startB - startA
829
834
for ( ; ; ) {
830
- let diff = ( a . to + dPos ) - b . to || a . endSide - b . endSide
835
+ let dEnd = ( a . to + dPos ) - b . to , diff = dEnd || a . endSide - b . endSide
831
836
let end = diff < 0 ? a . to + dPos : b . to , clipEnd = Math . min ( end , endB )
832
837
if ( a . point || b . point ) {
833
838
if ( ! ( a . point && b . point && ( a . point == b . point || a . point . eq ( b . point ) ) &&
834
839
sameValues ( a . activeForPoint ( a . to ) , b . activeForPoint ( b . to ) ) ) )
835
840
comparator . comparePoint ( pos , clipEnd , a . point , b . point )
836
841
} else {
837
842
if ( clipEnd > pos && ! sameValues ( a . active , b . active ) ) comparator . compareRange ( pos , clipEnd , a . active , b . active )
843
+ else if ( end < endB && ( dEnd || a . openEnd != b . openEnd ) && comparator . boundChange ) comparator . boundChange ( clipEnd )
838
844
}
839
845
if ( end > endB ) break
840
846
pos = end
0 commit comments