1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 00:42:33 +03:00

Try negating the offset.

This commit is contained in:
Rob Rix 2015-12-14 12:34:18 -05:00
parent 4cd2b2db7a
commit 4dd9907130

View File

@ -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