Skip to content

Commit

Permalink
fix: avoid emitting empty ansi color codes
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
lnu authored and JanDeDobbeleer committed Dec 27, 2020
1 parent 077b839 commit 969b544
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ansi_color.go
Expand Up @@ -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)
Expand Down

0 comments on commit 969b544

Please sign in to comment.