mirror of
https://github.com/github/semantic.git
synced 2025-01-03 13:02:37 +03:00
Properly calculate range for subterms
This commit is contained in:
parent
ac4df9a7b3
commit
7ba739a508
@ -20,6 +20,10 @@ rangeAt a = Range a a
|
||||
rangeLength :: Range -> Int
|
||||
rangeLength range = end range - start range
|
||||
|
||||
-- | Subtract an offset from a Range.
|
||||
subtractRange :: Range -> Int -> Range
|
||||
subtractRange a b = Range (start a - b) (end a - b)
|
||||
|
||||
-- | Return a range that covers the entire text.
|
||||
-- totalRange :: Foldable f => f a -> Range
|
||||
-- totalRange t = Range 0 $ length t
|
||||
|
@ -9,6 +9,7 @@ import Data.Record
|
||||
import Diff
|
||||
import Info
|
||||
import Prologue
|
||||
import Range
|
||||
import qualified Data.List as List
|
||||
import qualified Data.Map as Map hiding (null)
|
||||
import Renderer
|
||||
@ -164,5 +165,6 @@ toTermName source term = case unwrap term of
|
||||
_ -> toText source
|
||||
where
|
||||
toTermName' :: SyntaxTerm leaf fields -> Text
|
||||
toTermName' subterm = toTermName (Source.slice (range subterm) source) subterm
|
||||
toTermName' subterm = toTermName (Source.slice (range' subterm) source) subterm
|
||||
range' subterm = subtractRange (range subterm) (start (range term))
|
||||
range = characterRange . extract
|
||||
|
Loading…
Reference in New Issue
Block a user