1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 06:11:49 +03:00

Use the Alternative instance for skipping spaces too.

This commit is contained in:
Rob Rix 2015-12-14 16:34:52 -05:00
parent 645ae0b6de
commit 44c11647f8

View File

@ -18,12 +18,9 @@ offsetRange i (Range start end) = Range (i + start) (i + end)
rangesAndWordsFrom :: Int -> String -> [(Range, String)]
rangesAndWordsFrom _ "" = []
rangesAndWordsFrom startIndex string =
case takeAndContinue <$> (word <|> punctuation) of
case takeAndContinue <$> (word <|> punctuation) <|> skipAndContinue <$> space of
Just a -> a
Nothing ->
case space of
Just parsed -> skipAndContinue parsed
Nothing -> []
Nothing -> []
where
word = parse isWord string
punctuation = parse (not . isWordOrSpace) string