1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 09:55:52 +03:00

Avoid most of the conversions into/out of Source.

This commit is contained in:
Rob Rix 2015-12-23 23:17:35 -05:00
parent a19115b267
commit 588b1a68ee

View File

@ -155,11 +155,10 @@ zipWithDefaults f da db a b = take (max (length a) (length b)) $ zipWith f (a ++
actualLines :: Source Char -> [Source Char]
actualLines source | length source == 0 = [ source ]
actualLines source = makeSource <$> actualLines (toString source)
where actualLines lines = case break (== '\n') lines of
(l, lines') -> case lines' of
[] -> [ l ]
_:lines' -> (l ++ "\n") : actualLines lines'
actualLines source = case Source.break (== '\n') source of
(l, lines') -> case uncons lines' of
Nothing -> [ l ]
Just (_, lines') -> (makeSource $ toString l ++ "\n") : actualLines lines'
-- | Compute the line ranges within a given range of a string.
actualLineRanges :: Range -> Source Char -> [Range]