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

Correct rangesOfWordsFrom to produce start/end ranges, not start/length ranges.

This commit is contained in:
Rob Rix 2015-12-14 12:49:51 -05:00
parent 1bdfa51702
commit 58830283d4

View File

@ -18,8 +18,8 @@ rangesOfWordsFrom :: Int -> String -> [Range]
rangesOfWordsFrom startIndex string = case break Char.isSpace string of
([], []) -> []
([], rest) -> rangesOfWordsAfterWhitespace startIndex rest
(word, []) -> [ Range startIndex $ length word ]
(word, rest) -> (Range startIndex $ length word) : rangesOfWordsAfterWhitespace (startIndex + length word) rest
(word, []) -> [ Range startIndex $ startIndex + length word ]
(word, rest) -> (Range startIndex $ startIndex + length word) : rangesOfWordsAfterWhitespace (startIndex + length word) rest
where
rangesOfWordsAfterWhitespace startIndex string | (whitespace, rest) <- break (not . Char.isSpace) string = rangesOfWordsFrom (startIndex + length whitespace) rest