1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 00:33:59 +03:00

Correct the computation of range intersection.

This commit is contained in:
Rob Rix 2016-05-27 14:22:45 -04:00
parent ccd45ccecb
commit 835f38bdf8

View File

@ -50,8 +50,7 @@ maybeLastIndex (Range _ end) = Just $ end - 1
-- | Test two ranges for intersection.
intersectsRange :: Range -> Range -> Bool
intersectsRange range1 range2 = isWellFormedAndNonEmpty $ intersectionRange range1 range2
where isWellFormedAndNonEmpty range = start range < end range
intersectsRange range1 range2 = (start range1 > start range2 && start range1 < end range2) || (start range2 > start range1 && start range2 < end range1)
-- Return the (possibly empty, possibly ill-formed) intersection of two ranges.
intersectionRange :: Range -> Range -> Range