From 07190fb6d122645adaf1fe963fcd00d058daa166 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 30 May 2016 19:04:16 -0400 Subject: [PATCH 1/4] Add a regression test for #573. --- test/crashers/573.A.js | 2 ++ test/crashers/573.B.js | 1 + 2 files changed, 3 insertions(+) create mode 100644 test/crashers/573.A.js create mode 100644 test/crashers/573.B.js diff --git a/test/crashers/573.A.js b/test/crashers/573.A.js new file mode 100644 index 000000000..013a570e0 --- /dev/null +++ b/test/crashers/573.A.js @@ -0,0 +1,2 @@ +if (a && + b) {} diff --git a/test/crashers/573.B.js b/test/crashers/573.B.js new file mode 100644 index 000000000..c9e37d4c8 --- /dev/null +++ b/test/crashers/573.B.js @@ -0,0 +1 @@ +if (a && b) {} From 70bb48b9330e60d364b8f60606142901dde03bed Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 30 May 2016 19:15:46 -0400 Subject: [PATCH 2/4] Sort children before rendering in split diffs. --- src/Renderer/Split.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Renderer/Split.hs b/src/Renderer/Split.hs index 363876811..987b43f59 100644 --- a/src/Renderer/Split.hs +++ b/src/Renderer/Split.hs @@ -94,9 +94,9 @@ newtype Renderable a = Renderable a instance ToMarkup f => ToMarkup (Renderable (Source Char, Info, Syntax a (f, Range))) where toMarkup (Renderable (source, Info range categories size, syntax)) = (! A.data_ (stringValue (show size))) . classifyMarkup categories $ case syntax of Leaf _ -> span . string . toString $ slice range source - Indexed children -> ul . mconcat $ wrapIn li <$> contentElements source range children - Fixed children -> ul . mconcat $ wrapIn li <$> contentElements source range children - Keyed children -> dl . mconcat $ wrapIn dd <$> contentElements source range children + Indexed children -> ul . mconcat $ wrapIn li <$> contentElements source range (sortBy (compare `on` Prologue.snd) children) + Fixed children -> ul . mconcat $ wrapIn li <$> contentElements source range (sortBy (compare `on` Prologue.snd) children) + Keyed children -> dl . mconcat $ wrapIn dd <$> contentElements source range (sortBy (compare `on` Prologue.snd) (toList children)) contentElements :: (Foldable t, ToMarkup f) => Source Char -> Range -> t (f, Range) -> [Markup] contentElements source range children = let (elements, next) = foldr' (markupForContextAndChild source) ([], end range) children in From e44d629380d8335e3d7b78738acf2b59e090c346 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 30 May 2016 19:20:50 -0400 Subject: [PATCH 3/4] Revert "Sort children before rendering in split diffs." This reverts commit d989a76742d1e725935a1dea1a349778a67c5c32. --- src/Renderer/Split.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Renderer/Split.hs b/src/Renderer/Split.hs index 987b43f59..363876811 100644 --- a/src/Renderer/Split.hs +++ b/src/Renderer/Split.hs @@ -94,9 +94,9 @@ newtype Renderable a = Renderable a instance ToMarkup f => ToMarkup (Renderable (Source Char, Info, Syntax a (f, Range))) where toMarkup (Renderable (source, Info range categories size, syntax)) = (! A.data_ (stringValue (show size))) . classifyMarkup categories $ case syntax of Leaf _ -> span . string . toString $ slice range source - Indexed children -> ul . mconcat $ wrapIn li <$> contentElements source range (sortBy (compare `on` Prologue.snd) children) - Fixed children -> ul . mconcat $ wrapIn li <$> contentElements source range (sortBy (compare `on` Prologue.snd) children) - Keyed children -> dl . mconcat $ wrapIn dd <$> contentElements source range (sortBy (compare `on` Prologue.snd) (toList children)) + Indexed children -> ul . mconcat $ wrapIn li <$> contentElements source range children + Fixed children -> ul . mconcat $ wrapIn li <$> contentElements source range children + Keyed children -> dl . mconcat $ wrapIn dd <$> contentElements source range children contentElements :: (Foldable t, ToMarkup f) => Source Char -> Range -> t (f, Range) -> [Markup] contentElements source range children = let (elements, next) = foldr' (markupForContextAndChild source) ([], end range) children in From b7e724effd30bf61e8b066a7479ac3c97fdfc45e Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 30 May 2016 19:21:06 -0400 Subject: [PATCH 4/4] Sort the produced children by range. --- src/Alignment.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Alignment.hs b/src/Alignment.hs index bdc89f3be..4d398a2f4 100644 --- a/src/Alignment.hs +++ b/src/Alignment.hs @@ -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])