scribble/eval: fix error line wrapping

The `wrap-line' function from `scribble/text/wrap' wants a
string that's a single line, so break the initial string
based on explicit lines, first.

original commit: 9b7ef7bf699c7997ad2c254827ca6528491a6f10
This commit is contained in:
Matthew Flatt 2012-05-25 06:41:25 -06:00
parent aaad158068
commit 45e9a0fd33

View File

@ -105,11 +105,14 @@
flow-accum)]))))
(define (string->wrapped-lines str)
(wrap-line str maxlen
(λ (word fits)
(if ((string-length word) . > . maxlen)
(values (substring word 0 fits) (substring word fits) #f)
(values #f word #f)))))
(apply
append
(for/list ([line-str (regexp-split #rx"\n" str)])
(wrap-line line-str maxlen
(λ (word fits)
(if ((string-length word) . > . maxlen)
(values (substring word 0 fits) (substring word fits) #f)
(values #f word #f)))))))
(struct formatted-result (content))
@ -128,7 +131,11 @@
(cond
[(string? (caar val-list+outputs))
;; Error result case:
(map (lambda (s) (car (format-output s error-color)))
(map (lambda (s)
(define p (format-output s error-color))
(if (null? p)
(list null)
(car p)))
(string->wrapped-lines (caar val-list+outputs)))]
[(box? (caar val-list+outputs))
;; Output written to a port