Update DebuggerSupport.swift

This commit is contained in:
Alejandro Alonso
2024-05-15 10:02:35 -07:00
parent 180a11fdc2
commit b2f21bbfb3
3 changed files with 15 additions and 4 deletions

View File

@@ -148,8 +148,6 @@ public enum _DebuggerSupport {
return count == 1 ? "1 element" : "\(count) elements"
case .`struct`?, .`enum`?, nil:
switch value {
case let x as String:
return x.description
case let x as CustomDebugStringConvertible:
return x.debugDescription
case let x as CustomStringConvertible:
@@ -240,7 +238,13 @@ public enum _DebuggerSupport {
print("\(name) : ", terminator: "", to: &target)
}
if let str = asStringRepresentation(value: value, mirror: mirror, count: count) {
if isRoot, let value = value as? String {
// We don't want to use string's debug desciprtion for 'po' because it
// escapes the string and prints it raw (e.g. prints "\n" instead of
// actually printing a newline), but only if its the root value. Otherwise,
// continue using the debug description.
print(value, terminator: "", to: &target)
} else if let str = asStringRepresentation(value: value, mirror: mirror, count: count) {
print(str, terminator: "", to: &target)
}