diff --git a/src/Alignment.hs b/src/Alignment.hs index 55ec330a8..2c86cb4ba 100644 --- a/src/Alignment.hs +++ b/src/Alignment.hs @@ -94,6 +94,12 @@ splitAnnotatedByLines sources ranges categories syntax = case syntax of wrap :: Copointed f => ([f (SplitDiff leaf Info)] -> Syntax leaf (SplitDiff leaf Info)) -> Set.Set Category -> [(Range, Maybe (f (SplitDiff leaf Info)))] -> SplitDiff leaf Info wrap constructor categories children = Free . Annotated (Info (unionRanges $ Prelude.fst <$> children) categories) . constructor . catMaybes $ Prelude.snd <$> children + getRange :: Copointed f => Either Range (f (SplitDiff leaf Info)) -> Range + getRange (Right diff) = case copoint diff of + (Pure patch) -> let Info range _ :< _ = getSplitTerm patch in range + (Free (Annotated (Info range _) _)) -> range + getRange (Left range) = range + childRows :: (Copointed f, Functor f) => ([Row (Range, Maybe (f (SplitDiff leaf Info)))], Both Int) -> f (Diff leaf Info) -> ([Row (Range, Maybe (f (SplitDiff leaf Info)))], Both Int) childRows (rows, previous) child = let (childRows, childRanges) = splitDiffByLines (copoint child) previous sources in (adjoin $ rows ++ (fmap (flip (,) Nothing) <$> contextRows (makeRanges previous (start <$> childRanges)) sources) ++ (rowMap ((. (Just . (<$ child))) . (,) <$> childRanges) <$> childRows), end <$> childRanges)