mirror of
https://github.com/github/semantic.git
synced 2024-12-01 09:15:01 +03:00
Map the diffs into functions first up.
This commit is contained in:
parent
dde8612347
commit
bd0d8f0d02
@ -114,11 +114,11 @@ instance Eq PrettyDiff where
|
|||||||
(==) = (==) `on` unPrettyLines
|
(==) = (==) `on` unPrettyLines
|
||||||
|
|
||||||
instance Show PrettyDiff where
|
instance Show PrettyDiff where
|
||||||
show (PrettyDiff sources lines) = intercalate "\n" (showLine 40 <$> lines)
|
show (PrettyDiff sources lines) = intercalate "\n" (showLine 40 . fmap showDiff <$> lines)
|
||||||
where showLine n line = case runJoin line of
|
where showLine n line = case runJoin line of
|
||||||
This before -> pad n (showDiff before (fst sources)) " | "
|
This before -> pad n (before (fst sources)) " | "
|
||||||
That after -> showString (replicate n ' ') (showString " | " (showDiff after (snd sources)))
|
That after -> showString (replicate n ' ') (showString " | " (after (snd sources)))
|
||||||
These before after -> pad n (showDiff before (fst sources)) (showString " | " (showDiff after (snd sources)))
|
These before after -> pad n (before (fst sources)) (showString " | " (after (snd sources)))
|
||||||
showDiff diff = toList . stripNewlines . Source.slice (getRange diff)
|
showDiff diff = toList . stripNewlines . Source.slice (getRange diff)
|
||||||
stripNewlines = fmap (\ c -> if c == '\n' then ' ' else c)
|
stripNewlines = fmap (\ c -> if c == '\n' then ' ' else c)
|
||||||
pad n string = showString string . showString (replicate (max 0 (n - length string)) ' ')
|
pad n string = showString string . showString (replicate (max 0 (n - length string)) ' ')
|
||||||
|
Loading…
Reference in New Issue
Block a user