Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Sources/swift-format/Utilities/StderrDiagnosticPrinter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ final class StderrDiagnosticPrinter {
case boldRed = "1;31"
case boldYellow = "1;33"
case boldMagenta = "1;35"
case boldWhite = "1;37"
case boldGray = "1;90"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we actually have any right now, but presumably boldGray has similar issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like boldGray is used for note-level emissions, which are used by a handful of rules for notes attached to their primary warning. I ran a quick test on my active theme and one of the built-in themes in the macOS Terminal, and it does seem pretty low-contrast in both versions 😅

image image

I wonder if we can downgrade that to just bold if we also take @allevato's suggestion of printing the location in plain (non-bold) text... 🤔

case bold = "1"
case reset = "0"
}

Expand All @@ -61,18 +61,18 @@ final class StderrDiagnosticPrinter {
printQueue.sync {
let stderr = FileHandleTextOutputStream(FileHandle.standardError)

stderr.write("\(ansiSGR(.boldWhite))\(description(of: diagnostic.location)): ")
stderr.write("\(ansiSGR(.reset))\(description(of: diagnostic.location)): ")

switch diagnostic.severity {
case .error: stderr.write("\(ansiSGR(.boldRed))error: ")
case .warning: stderr.write("\(ansiSGR(.boldMagenta))warning: ")
case .warning: stderr.write("\(ansiSGR(.boldYellow))warning: ")
case .note: stderr.write("\(ansiSGR(.boldGray))note: ")
}

if let category = diagnostic.category {
stderr.write("\(ansiSGR(.boldYellow))[\(category)] ")
stderr.write("\(ansiSGR(.boldMagenta))[\(category)] ")
}
stderr.write("\(ansiSGR(.boldWhite))\(diagnostic.message)\(ansiSGR(.reset))\n")
stderr.write("\(ansiSGR(.reset))\(ansiSGR(.bold))\(diagnostic.message)\(ansiSGR(.reset))\n")
}
}

Expand Down
Loading