Skip to content

Commit dfaa54b

Browse files
committed
fix(config): prevent empty color values in chroma style generation
- add empty string checks for color and background color values - return "inherit" when no style properties are set - prevent invalid empty color strings from being processed
1 parent 420d050 commit dfaa54b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

internal/config/style.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,10 @@ func NewProperties(properties string) (Properties, error) {
279279
func ChromaStyle(style ansi.StylePrimitive) string {
280280
var s string
281281

282-
if style.Color != nil {
282+
if style.Color != nil && *style.Color != "" {
283283
s = *style.Color
284284
}
285-
if style.BackgroundColor != nil {
285+
if style.BackgroundColor != nil && *style.BackgroundColor != "" {
286286
if s != "" {
287287
s += " "
288288
}
@@ -307,6 +307,10 @@ func ChromaStyle(style ansi.StylePrimitive) string {
307307
s += "underline"
308308
}
309309

310+
if s == "" {
311+
return "inherit"
312+
}
313+
310314
return s
311315
}
312316

0 commit comments

Comments
 (0)