mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
Make unified into a Renderer of [Chunk String]
This commit is contained in:
parent
a166c354e3
commit
b074325f67
@ -60,9 +60,11 @@ diff = interpret comparable
|
||||
-- | Return a renderer from the command-line arguments that will print the diff.
|
||||
printDiff :: Arguments -> Renderer T.Text (IO ())
|
||||
printDiff arguments diff sources = case format arguments of
|
||||
Unified -> B1.putStr =<< render <$> byteStringMakerFromEnvironment
|
||||
Unified -> put $ unified diff sources
|
||||
where
|
||||
render renderer = unified renderer diff sources
|
||||
put chunks = do
|
||||
renderer <- byteStringMakerFromEnvironment
|
||||
B1.putStr $ mconcat $ chunksToByteStrings renderer chunks
|
||||
Split -> put (output arguments) =<< split diff sources
|
||||
where
|
||||
put Nothing rendered = TextIO.putStr rendered
|
||||
|
@ -15,8 +15,8 @@ import qualified Data.OrderedMap as Map
|
||||
import Rainbow
|
||||
|
||||
-- | Render a diff with the unified format.
|
||||
unified :: (Chunk String -> [ByteString] -> [ByteString]) -> Renderer a ByteString
|
||||
unified renderer diff (before, after) = mconcat . chunksToByteStrings renderer . fst $ iter g mapped
|
||||
unified :: Renderer a [Chunk String]
|
||||
unified diff (before, after) = fst $ iter g mapped
|
||||
where
|
||||
mapped = fmap (unifiedPatch &&& range) diff
|
||||
g (Annotated (_, info) syntax) = annotationAndSyntaxToChunks after info syntax
|
||||
|
Loading…
Reference in New Issue
Block a user