summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-12-22 08:10:29 +0300
committerdefanor <defanor@uberspace.net>2017-12-22 08:10:29 +0300
commit14468d50a6b22c67e656cd2b2a5fb4c7dad692b2 (patch)
treeaba20c3cb575404753fa9089ae3e2d0e2d8ca701
parent5762a064e7cc4a96f1b1cfdf27be073f757a65d7 (diff)
downloadpancake-14468d50a6b22c67e656cd2b2a5fb4c7dad692b2.zip
pancake-14468d50a6b22c67e656cd2b2a5fb4c7dad692b2.tar.gz
pancake-14468d50a6b22c67e656cd2b2a5fb4c7dad692b2.tar.bz2
Handle newlines in storeLines
Usually there's none, but now it's possible for them to get there with --no-wrap. Perhaps that should be fixed too.
-rw-r--r--Pancake/Rendering.hs3
1 files changed, 2 insertions, 1 deletions
diff --git a/Pancake/Rendering.hs b/Pancake/Rendering.hs
index b5fd717..112bbbb 100644
--- a/Pancake/Rendering.hs
+++ b/Pancake/Rendering.hs
@@ -204,7 +204,8 @@ storeNote ro = do
-- | Stores text lines.
storeLines :: [StyledLine] -> Renderer ()
storeLines l = do
- modify (\s -> s { lineNumber = lineNumber s + length l })
+ let newlines = sum $ map (length . filter (== '\n') . unstyled) l
+ modify (\s -> s { lineNumber = lineNumber s + length l + newlines })
tell $ map RLine l
-- | Stores attributes (identifier and line number).