mirror of
https://github.com/github/semantic.git
synced 2024-12-24 23:42:31 +03:00
Add a toPrettyDiff function to abstract the construction of pretty diffs away.
This commit is contained in:
parent
24a732322c
commit
e0e7f0fa4a
@ -218,6 +218,11 @@ toAlignedChildren = join . (`evalState` both 0 0) . mapM go
|
||||
put $ (+) <$> prev <*> modifyJoin (fromThese 0 0) (length <$> contents)
|
||||
return []
|
||||
|
||||
toPrettyDiff :: [BranchElement] -> PrettyDiff [(String, Range)]
|
||||
toPrettyDiff elements = PrettyDiff sources (alignBranch id children ranges)
|
||||
where (sources, ranges) = toSourcesAndRanges elements
|
||||
children = toAlignedChildren elements
|
||||
|
||||
instance Arbitrary BranchElement where
|
||||
arbitrary = oneof [ key >>= \ key -> Child key <$> joinTheseOf (contents key)
|
||||
, Margin <$> joinTheseOf margin ]
|
||||
|
Loading…
Reference in New Issue
Block a user