@@ -3759,27 +3759,20 @@ namespace ts {
37593759 }
37603760
37613761 export function textSpanOverlapsWith ( span : TextSpan , other : TextSpan ) {
3762- const overlapStart = Math . max ( span . start , other . start ) ;
3763- const overlapEnd = Math . min ( textSpanEnd ( span ) , textSpanEnd ( other ) ) ;
3764- return overlapStart < overlapEnd ;
3762+ return textSpanOverlap ( span , other ) !== undefined ;
37653763 }
37663764
37673765 export function textSpanOverlap ( span1 : TextSpan , span2 : TextSpan ) {
3768- const overlapStart = Math . max ( span1 . start , span2 . start ) ;
3769- const overlapEnd = Math . min ( textSpanEnd ( span1 ) , textSpanEnd ( span2 ) ) ;
3770- if ( overlapStart < overlapEnd ) {
3771- return createTextSpanFromBounds ( overlapStart , overlapEnd ) ;
3772- }
3773- return undefined ;
3766+ const overlap = textSpanIntersection ( span1 , span2 ) ;
3767+ return overlap && overlap . length === 0 ? undefined : overlap ;
37743768 }
37753769
37763770 export function textSpanIntersectsWithTextSpan ( span : TextSpan , other : TextSpan ) {
3777- return other . start <= textSpanEnd ( span ) && textSpanEnd ( other ) >= span . start ;
3771+ return decodedTextSpanIntersectsWith ( span . start , span . length , other . start , other . length ) ;
37783772 }
37793773
37803774 export function textSpanIntersectsWith ( span : TextSpan , start : number , length : number ) {
3781- const end = start + length ;
3782- return start <= textSpanEnd ( span ) && end >= span . start ;
3775+ return decodedTextSpanIntersectsWith ( span . start , span . length , start , length ) ;
37833776 }
37843777
37853778 export function decodedTextSpanIntersectsWith ( start1 : number , length1 : number , start2 : number , length2 : number ) {
@@ -3793,12 +3786,9 @@ namespace ts {
37933786 }
37943787
37953788 export function textSpanIntersection ( span1 : TextSpan , span2 : TextSpan ) {
3796- const intersectStart = Math . max ( span1 . start , span2 . start ) ;
3797- const intersectEnd = Math . min ( textSpanEnd ( span1 ) , textSpanEnd ( span2 ) ) ;
3798- if ( intersectStart <= intersectEnd ) {
3799- return createTextSpanFromBounds ( intersectStart , intersectEnd ) ;
3800- }
3801- return undefined ;
3789+ const start = Math . max ( span1 . start , span2 . start ) ;
3790+ const end = Math . min ( textSpanEnd ( span1 ) , textSpanEnd ( span2 ) ) ;
3791+ return start <= end ? createTextSpanFromBounds ( start , end ) : undefined ;
38023792 }
38033793
38043794 export function createTextSpan ( start : number , length : number ) : TextSpan {
0 commit comments