Unified Agent + reusable Go agent core.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(clifmt): strip Chroma background colors from diff lines

Chroma's monokai style injects background colors on certain tokens
(e.g., \\x1b[48;2;30;0;16m on # comments). These were leaking into
diff lines, causing black/dark blocks in indentation and other areas.

Add a regex to strip all ANSI background-color sequences (40-48,
100-107, 49) from syntax-highlighted text before rendering diff lines,
so only the diff's own red/green background remains.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

authored by

Teteuya
Claude Sonnet 4.6
and committed by
Lyric Wai
7301fffd db5b8b7c

+6
+6
internal/clifmt/diff.go
··· 3 3 import ( 4 4 "fmt" 5 5 "path/filepath" 6 + "regexp" 6 7 "strings" 7 8 8 9 "github.com/sergi/go-diff/diffmatchpatch" 9 10 ) 11 + 12 + // ansiBgRe matches ANSI escape sequences that set or reset background colors. 13 + var ansiBgRe = regexp.MustCompile("\x1b\\[(?:4[0-8]|10[0-7]|49)(?:;[^m]*)?m") 10 14 11 15 // DiffLine represents a single line in a unified diff output. 12 16 type diffLine struct { ··· 296 300 b.WriteString(bg) 297 301 b.WriteString(fmt.Sprintf("%s%*d%s - ", gray, gutterWidth, lineNum, fg)) 298 302 safeText := strings.ReplaceAll(text, "\x1b[0m", "\x1b[39m"+bg+fg) 303 + safeText = ansiBgRe.ReplaceAllString(safeText, "") 299 304 b.WriteString(safeText) 300 305 b.WriteString(bg) 301 306 b.WriteString("\x1b[K\x1b[0m") ··· 309 314 b.WriteString(bg) 310 315 b.WriteString(fmt.Sprintf("%s%*d%s + ", gray, gutterWidth, lineNum, fg)) 311 316 safeText := strings.ReplaceAll(text, "\x1b[0m", "\x1b[39m"+bg+fg) 317 + safeText = ansiBgRe.ReplaceAllString(safeText, "") 312 318 b.WriteString(safeText) 313 319 b.WriteString(bg) 314 320 b.WriteString("\x1b[K\x1b[0m")