1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 18:23:44 +03:00

Recompute term sizes after replacing multi-word leaves.

This commit is contained in:
Rob Rix 2016-04-12 11:22:02 -04:00
parent 9a5dca4558
commit 851d53fa07

View File

@ -56,7 +56,7 @@ breakDownLeavesByWord source = cata replaceIn
replaceIn (Info range categories _) (Leaf _) | ranges <- rangesAndWordsInSource range
, length ranges > 1
= Info range categories (1 + fromIntegral (length ranges)) :< Indexed (makeLeaf categories <$> ranges)
replaceIn info syntax = info :< syntax
replaceIn info@(Info range categories _) syntax = Info range categories (1 + sum (size . copoint <$> syntax)) :< syntax
rangesAndWordsInSource range = rangesAndWordsFrom (start range) (toString $ slice range source)
makeLeaf categories (range, substring) = Info range categories 1 :< Leaf (T.pack substring)