@@ -202,18 +202,17 @@ chomp d = Doc (fromList dl')
203outp :: (IsString a, Monoid a)
203outp :: (IsString a, Monoid a)
204 => Int -> String -> DocState a
204 => Int -> String -> DocState a
205−outp off s | off <= 0 = do
205+outp off s | off < 0 = do -- offset < 0 means newline characters
206 st' <- get
206 st' <- get
207 let rawpref = prefix st'
207 let rawpref = prefix st'
208 when (column st' == 0 && usePrefix st' && not (null rawpref)) $ do
208 when (column st' == 0 && usePrefix st' && not (null rawpref)) $ do
209 let pref = reverse $ dropWhile isSpace $ reverse rawpref
209 let pref = reverse $ dropWhile isSpace $ reverse rawpref
210 modify $ \st -> st{ output = fromString pref : output st
210 modify $ \st -> st{ output = fromString pref : output st
211 , column = column st + realLength pref }
211 , column = column st + realLength pref }
213− modify $ \st -> st { output = fromString s : output st
212+ modify $ \st -> st { output = fromString s : output st
214− , column = 0
213+ , column = 0
215− , newlines = newlines st + 1 }
214+ , newlines = newlines st + 1 }
216−outp off s = do
215+outp off s = do -- offset >= 0 (0 might be combining char)
217 st' <- get
216 st' <- get
218 let pref = prefix st'
217 let pref = prefix st'
219 when (column st' == 0 && usePrefix st' && not (null pref)) $ do
218 when (column st' == 0 && usePrefix st' && not (null pref)) $ do