mirror of
https://github.com/github/semantic.git
synced 2024-11-29 02:44:36 +03:00
Transpose replacements through unPatch.
This commit is contained in:
parent
a281f4d2e6
commit
f646a14d3b
@ -51,7 +51,7 @@ splitPatchByLines patch previous sources = case patch of
|
||||
Delete term -> let (lines, range) = splitAbstractedTerm copoint unwrap (:<) (fst sources) term in
|
||||
(flip makeRow EmptyLine . fmap (Pure . SplitDelete) <$> lines, both range (rangeAt $ snd previous))
|
||||
Replace leftTerm rightTerm -> (zipWithDefaults makeRow (pure mempty) $ fmap (fmap (Pure . SplitReplace)) <$> lines, ranges)
|
||||
where (lines, ranges) = transpose $ splitAbstractedTerm copoint unwrap (:<) <$> sources <*> both leftTerm rightTerm
|
||||
where Just (lines, ranges) = fmap transpose . sequenceA $ fmap . splitAbstractedTerm copoint unwrap (:<) <$> sources <*> unPatch patch
|
||||
|
||||
-- | Split an `inTerm` (abstracted by two destructors) up into one `outTerm` (abstracted by a constructor) per line in `Source`.
|
||||
splitAbstractedTerm :: (inTerm -> Info) -> (inTerm -> Syntax leaf inTerm) -> (Info -> Syntax leaf outTerm -> outTerm) -> Source Char -> inTerm -> ([Line outTerm], Range)
|
||||
|
Loading…
Reference in New Issue
Block a user