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)