[commit: haddock] master: Adapt source span tagging to work with current whitespace handling. (57d4c9c)
git at git.haskell.org
git at git.haskell.org
Wed Jul 8 08:39:32 UTC 2015
Repository : ssh://git@git.haskell.org/haddock
On branch : master
Link : http://git.haskell.org/haddock.git/commitdiff/57d4c9cff1d60f7dd0f8dafae5537218b63da90f
>---------------------------------------------------------------
commit 57d4c9cff1d60f7dd0f8dafae5537218b63da90f
Author: Łukasz Hanuszczak <lukasz.hanuszczak at gmail.com>
Date: Fri Jun 5 00:07:52 2015 +0200
Adapt source span tagging to work with current whitespace handling.
>---------------------------------------------------------------
57d4c9cff1d60f7dd0f8dafae5537218b63da90f
haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
index be6b7ce..53ff1f6 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
@@ -67,10 +67,13 @@ tag =
reverse . snd . foldl aux (Position 1 1, [])
where
aux (pos, cs) c =
- let pos' = if c == "\n"
- then pos { posRow = posRow pos + 1, posCol = 1 }
- else pos { posCol = posCol pos + length c }
- in (pos', (Span pos pos', c):cs)
+ let pos' = move pos c
+ in (pos', ((Span pos pos', c):cs))
+ move pos str@(c:_)
+ | isSpace c = foldl move' pos str
+ move pos str = pos { posCol = posCol pos + length str }
+ move' pos '\n' = pos { posRow = posRow pos + 1, posCol = 1 }
+ move' pos _ = pos { posCol = posCol pos + 1 }
tokenize :: [(Span, String)] -> [Token]
tokenize =
More information about the ghc-commits
mailing list