Fix applying multiple fixes per line

Fixes #1421
This commit is contained in:
Ng Zhi An 2018-12-21 14:34:03 +08:00
parent 08ca1ee6e9
commit 0636e7023c
3 changed files with 48 additions and 17 deletions

View file

@ -14,18 +14,9 @@ applyFix fix fileLines =
-- prereq: list is already sorted by start position
removeOverlap [] = []
removeOverlap (x:xs) = checkoverlap x xs
checkoverlap :: Replacement -> [Replacement] -> [Replacement]
checkoverlap x [] = x:[]
checkoverlap x (y:ys) =
if overlap x y then x:(removeOverlap ys) else x:y:(removeOverlap ys)
-- two position overlaps when
overlap x y =
(yStart >= xStart && yStart < xEnd) || (yStart < xStart && yEnd > xStart)
where
yStart = repStartPos y
yEnd = repEndPos y
xStart = repStartPos x
xEnd = repEndPos x
-- A replacement that spans multiple line is applied by: