mirror of
https://github.com/github/semantic.git
synced 2025-01-01 11:46:14 +03:00
Avoid most of the conversions into/out of Source.
This commit is contained in:
parent
a19115b267
commit
588b1a68ee
@ -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 Char -> [Source Char]
|
||||||
actualLines source | length source == 0 = [ source ]
|
actualLines source | length source == 0 = [ source ]
|
||||||
actualLines source = makeSource <$> actualLines (toString source)
|
actualLines source = case Source.break (== '\n') source of
|
||||||
where actualLines lines = case break (== '\n') lines of
|
(l, lines') -> case uncons lines' of
|
||||||
(l, lines') -> case lines' of
|
Nothing -> [ l ]
|
||||||
[] -> [ l ]
|
Just (_, lines') -> (makeSource $ toString l ++ "\n") : actualLines lines'
|
||||||
_:lines' -> (l ++ "\n") : actualLines lines'
|
|
||||||
|
|
||||||
-- | Compute the line ranges within a given range of a string.
|
-- | Compute the line ranges within a given range of a string.
|
||||||
actualLineRanges :: Range -> Source Char -> [Range]
|
actualLineRanges :: Range -> Source Char -> [Range]
|
||||||
|
Loading…
Reference in New Issue
Block a user