1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 23:11:50 +03:00

Unpack the Rows and apply snd.

This commit is contained in:
Rob Rix 2016-03-09 01:00:04 -05:00
parent ebbf19953e
commit b3ec4e771e

View File

@ -52,12 +52,12 @@ lineLength _ = 1
-- | Given the before and after sources, render a hunk to a string.
showHunk :: Both SourceBlob -> Hunk (SplitDiff a Info) -> String
showHunk blobs hunk = header blobs hunk ++ concat (showChange sources <$> changes hunk) ++ showLines (snd sources) ' ' (unRight <$> trailingContext hunk)
showHunk blobs hunk = header blobs hunk ++ concat (showChange sources <$> changes hunk) ++ showLines (snd sources) ' ' (snd . unRow <$> trailingContext hunk)
where sources = source <$> blobs
-- | Given the before and after sources, render a change to a string.
showChange :: Both (Source Char) -> Change (SplitDiff a Info) -> String
showChange sources change = showLines (snd sources) ' ' (unRight <$> context change) ++ deleted ++ inserted
showChange sources change = showLines (snd sources) ' ' (snd . unRow <$> context change) ++ deleted ++ inserted
where (deleted, inserted) = runBoth $ pure showLines <*> sources <*> Both ('-', '+') <*> Both.unzip (unRow <$> contents change)
-- | Given a source, render a set of lines to a string with a prefix.