@@ -304,18 +304,40 @@ extension Event.ConsoleOutputRecorder {
304
304
/// destination.
305
305
@discardableResult public func record( _ event: borrowing Event , in context: borrowing Event . Context ) -> Bool {
306
306
let messages = _humanReadableOutputRecorder. record ( event, in: context)
307
- for message in messages {
308
- let symbol = message. symbol? . stringValue ( options: options) ?? " "
309
307
310
- if case . details = message. symbol, options. useANSIEscapeCodes, options. ansiColorBitDepth > 1 {
308
+ // Padding to use in place of a symbol for messages that don't have one.
309
+ var padding = " "
310
+ #if os(macOS) || (os(iOS) && targetEnvironment(macCatalyst))
311
+ if options. useSFSymbols {
312
+ padding = " "
313
+ }
314
+ #endif
315
+
316
+ let lines = messages. lazy. map { [ test = context. test] message in
317
+ let symbol = message. symbol? . stringValue ( options: options) ?? padding
318
+
319
+ if case . details = message. symbol {
311
320
// Special-case the detail symbol to apply grey to the entire line of
312
- // text instead of just the symbol.
313
- write ( " \( _ansiEscapeCodePrefix) 90m \( symbol) \( message. stringValue) \( _resetANSIEscapeCode) \n " )
321
+ // text instead of just the symbol. Details may be multi-line messages,
322
+ // so split the message on newlines and indent all lines to align them
323
+ // to the indentation provided by the symbol.
324
+ var lines = message. stringValue. split ( whereSeparator: \. isNewline)
325
+ lines = CollectionOfOne ( lines [ 0 ] ) + lines. dropFirst ( ) . map { line in
326
+ " \( padding) \( line) "
327
+ }
328
+ let stringValue = lines. joined ( separator: " \n " )
329
+ if options. useANSIEscapeCodes, options. ansiColorBitDepth > 1 {
330
+ return " \( _ansiEscapeCodePrefix) 90m \( symbol) \( stringValue) \( _resetANSIEscapeCode) \n "
331
+ } else {
332
+ return " \( symbol) \( stringValue) \n "
333
+ }
314
334
} else {
315
- let colorDots = context . test. map ( \ . tags ) . map { self . colorDots ( for: $0) } ?? " "
316
- write ( " \( symbol) \( colorDots) \( message. stringValue) \n " )
335
+ let colorDots = test. map { self . colorDots ( for: $0. tags ) } ?? " "
336
+ return " \( symbol) \( colorDots) \( message. stringValue) \n "
317
337
}
318
338
}
339
+
340
+ write ( lines. joined ( ) )
319
341
return !messages. isEmpty
320
342
}
321
343
0 commit comments