From 6fc7632e93670ecc6842ef1cd6b8f6cf978102dd Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 14 Dec 2015 12:37:07 -0500 Subject: [PATCH] Only pass the start index around. --- app/Main.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index b299894a3..ff99710d1 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -62,13 +62,13 @@ parserForType mediaType = maybe P.lineByLineParser parseTreeSitterFile $ case me _ -> Nothing replaceLeavesWithWordBranches :: String -> Term String Info -> Term String Info -replaceLeavesWithWordBranches source term@(Info range _ _ :< _) = replaceIn source range term +replaceLeavesWithWordBranches source term = replaceIn source 0 term where - replaceIn source parentRange (info@(Info range lineRange categories) :< syntax) | range <- offsetRange (negate $ start parentRange) range = info :< case syntax of + replaceIn source startIndex (info@(Info range lineRange categories) :< syntax) | range <- offsetRange (negate $ startIndex) range = info :< case syntax of Leaf _ | ranges <- rangesOfWordsFrom (start range) (substring range source), length ranges > 1 -> Indexed $ makeLeaf source lineRange categories <$> ranges - Indexed i -> Indexed $ replaceIn (substring range source) range <$> i - Fixed f -> Fixed $ replaceIn (substring range source) range <$> f - Keyed k -> Keyed $ replaceIn (substring range source) range <$> k + Indexed i -> Indexed $ replaceIn (substring range source) (start range) <$> i + Fixed f -> Fixed $ replaceIn (substring range source) (start range) <$> f + Keyed k -> Keyed $ replaceIn (substring range source) (start range) <$> k _ -> syntax makeLeaf source lineRange categories range = Info range lineRange categories :< Leaf (substring range source)