mirror of
https://github.com/github/semantic.git
synced 2024-12-22 22:31:36 +03:00
Skip whitespace inline.
This commit is contained in:
parent
cded6c0d7d
commit
cee1da65b4
@ -17,7 +17,7 @@ offsetRange i (Range start end) = Range (i + start) (i + end)
|
|||||||
rangesAndWordsFrom :: Int -> String -> [(Range, String)]
|
rangesAndWordsFrom :: Int -> String -> [(Range, String)]
|
||||||
rangesAndWordsFrom startIndex string = case break (not . isWord) string of
|
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
|
(word, rest) -> (Range startIndex $ startIndex + length word, word) : rangesAndWordsAfterWhitespace (startIndex + length word) rest
|
||||||
where
|
where
|
||||||
rangesAndWordsAfterWhitespace startIndex string | (whitespace, rest) <- break isWord string = rangesAndWordsFrom (startIndex + length whitespace) rest
|
rangesAndWordsAfterWhitespace startIndex string | (whitespace, rest) <- break isWord string = rangesAndWordsFrom (startIndex + length whitespace) rest
|
||||||
|
Loading…
Reference in New Issue
Block a user