fix: avoid emitting empty ansi color codes

When there's no color override an empty string is emitted.
The fix reduces the emitted output by 40% approximatively with the default theme(1604 -> 1138).
This commit is contained in:
Laurent Nullens 2020-12-27 11:21:03 +01:00 committed by Jan De Dobbeleer
parent 077b839a9d
commit 969b54420a

View file

@ -92,6 +92,10 @@ func (a *AnsiColor) getAnsiFromColorString(colorString string, isBackground bool
}
func (a *AnsiColor) writeColoredText(background, foreground, text string) {
// Avoid emitting empty strings with color codes
if text == "" {
return
}
var coloredText string
if foreground == Transparent && background != "" {
ansiColor := a.getAnsiFromColorString(background, false)