1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 14:21:31 +03:00

Skip whitespace inline.

This commit is contained in:
Rob Rix 2015-12-14 15:55:02 -05:00
parent cded6c0d7d
commit cee1da65b4

View File

@ -17,7 +17,7 @@ offsetRange i (Range start end) = Range (i + start) (i + end)
rangesAndWordsFrom :: Int -> String -> [(Range, String)]
rangesAndWordsFrom startIndex string = case break (not . isWord) string of
([], []) -> []
([], rest) -> rangesAndWordsAfterWhitespace startIndex rest
([], rest) | (whitespace, rest) <- break isWord rest -> rangesAndWordsFrom (startIndex + length whitespace) rest
(word, rest) -> (Range startIndex $ startIndex + length word, word) : rangesAndWordsAfterWhitespace (startIndex + length word) rest
where
rangesAndWordsAfterWhitespace startIndex string | (whitespace, rest) <- break isWord string = rangesAndWordsFrom (startIndex + length whitespace) rest