1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 11:02:26 +03:00

Add showLines to show a list of lines with the same prefix.

This commit is contained in:
Rob Rix 2015-12-30 18:34:55 -05:00
parent 09b81a6c7f
commit 4ba7a017cc

View File

@ -43,6 +43,9 @@ showHunk sources hunk = header hunk ++ concat (showChange sources <$> changes hu
showChange :: (Source Char, Source Char) -> Change (SplitDiff a Info) -> String showChange :: (Source Char, Source Char) -> Change (SplitDiff a Info) -> String
showChange sources change = concat (showRow sources <$> context change) ++ fromMaybe "" (mconcat (fmap ('-' :) . showLine (fst sources) . unLeft <$> contents change)) ++ fromMaybe "" (mconcat (fmap ('+' :) . showLine (snd sources) . unRight <$> contents change)) showChange sources change = concat (showRow sources <$> context change) ++ fromMaybe "" (mconcat (fmap ('-' :) . showLine (fst sources) . unLeft <$> contents change)) ++ fromMaybe "" (mconcat (fmap ('+' :) . showLine (snd sources) . unRight <$> contents change))
showLines :: Source Char -> Char -> [Line (SplitDiff leaf Info)] -> String
showLines source prefix lines = fromMaybe "" . mconcat $ fmap (prefix :) . showLine source <$> lines
showRow :: (Source Char, Source Char) -> Row (SplitDiff leaf Info) -> String showRow :: (Source Char, Source Char) -> Row (SplitDiff leaf Info) -> String
showRow sources (Row lineA lineB) = if stringA == stringB showRow sources (Row lineA lineB) = if stringA == stringB
then maybe "" (' ' :) stringB then maybe "" (' ' :) stringB