1
1
mirror of https://github.com/github/semantic.git synced 2025-01-05 05:58:34 +03:00

Fold over both sides of the patch.

This commit is contained in:
Rob Rix 2017-09-14 14:56:45 -04:00
parent dc0debb961
commit 4645df37ba

View File

@ -19,6 +19,7 @@ module Renderer.TOC
import Data.Aeson
import Data.Align (bicrosswalk)
import Data.Bifoldable (bifoldMap)
import Data.Bifunctor (bimap)
import Data.Blob
import Data.ByteString.Lazy (toStrict)
@ -149,7 +150,7 @@ tableOfContentsBy :: (Foldable f, Functor f)
-> Diff f ann ann -- ^ The diff to compute the table of contents for.
-> [Entry a] -- ^ A list of entries for relevant changed and unchanged nodes in the diff.
tableOfContentsBy selector = fromMaybe [] . cata (\ r -> case r of
Patch patch -> (pure . patchEntry <$> bicrosswalk selector selector patch) <> foldMap fold patch <> Just []
Patch patch -> (pure . patchEntry <$> bicrosswalk selector selector patch) <> bifoldMap fold fold patch <> Just []
Merge (In (_, ann2) r) -> case (selector (In ann2 r), fold r) of
(Just a, Nothing) -> Just [Unchanged a]
(Just a, Just []) -> Just [Changed a]