1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 08:25:19 +03:00

Merge pull request #574 from github/fix-invalid-slice

Fix invalid slices in split diffs of certain reformatted nodes
This commit is contained in:
Josh Vera 2016-05-31 13:32:37 -04:00
commit f1b4529ad1
3 changed files with 4 additions and 1 deletions

View File

@ -104,7 +104,7 @@ alignBranch getRange children ranges = case intersectingChildren of
line $ alignBranch getRange (remaining ++ symmetricalChildren ++ nonIntersectingChildren) (modifyJoin (advanceBy (drop 1)) ranges)
lineAndRemaining _ Nothing = (identity, [])
lineAndRemaining children (Just ranges) = let (intersections, remaining) = alignChildren getRange children ranges in
((:) $ (,) <$> ranges `applyToBoth` intersections, remaining)
((:) $ (,) <$> ranges `applyToBoth` (sortBy (compare `on` getRange) <$> intersections), remaining)
-- | Given a list of aligned children, produce lists of their intersecting first lines, and a list of the remaining lines/nonintersecting first lines.
alignChildren :: (term -> Range) -> [Join These (term)] -> Join These Range -> (Both [term], [Join These term])

2
test/crashers/573.A.js Normal file
View File

@ -0,0 +1,2 @@
if (a &&
b) {}

1
test/crashers/573.B.js Normal file
View File

@ -0,0 +1 @@
if (a && b) {}