From 4dd9907130f55015c7e6d689725ae02fee2af250 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 14 Dec 2015 12:34:18 -0500 Subject: [PATCH] Try negating the offset. --- app/Main.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Main.hs b/app/Main.hs index 02fc19864..c2c103ed4 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -64,7 +64,7 @@ parserForType mediaType = maybe P.lineByLineParser parseTreeSitterFile $ case me replaceLeavesWithWordBranches :: String -> Term String Info -> Term String Info replaceLeavesWithWordBranches source term@(Info range _ _ :< _) = replaceIn source range term where - replaceIn source parentRange (info@(Info range lineRange categories) :< syntax) | range <- offsetRange (start parentRange) range = info :< case syntax of + replaceIn source parentRange (info@(Info range lineRange categories) :< syntax) | range <- offsetRange (negate $ start parentRange) range = info :< case syntax of Leaf _ | ranges <- rangesOfWordsFrom (start range) (substring range source), length ranges > 1 -> Indexed $ makeLeaf lineRange categories <$> ranges Indexed i -> Indexed $ replaceIn (substring range source) range <$> i Fixed f -> Fixed $ replaceIn (substring range source) range <$> f