From 45e9a0fd338a2fbcd58023aec2cf6edac6f66cff Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 25 May 2012 06:41:25 -0600 Subject: [PATCH] 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 --- collects/scribble/eval.rkt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/collects/scribble/eval.rkt b/collects/scribble/eval.rkt index 1e9440de..294e8532 100644 --- a/collects/scribble/eval.rkt +++ b/collects/scribble/eval.rkt @@ -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