Fixing number color issue

This commit is contained in:
Mike Farah
2025-12-20 15:12:30 +11:00
parent 4d620bfa26
commit 0914121d29
3 changed files with 124 additions and 3 deletions
+10 -2
View File
@@ -611,8 +611,16 @@ func (te *tomlEncoder) colorizeToml(input []byte) []byte {
if ch == '-' {
end++
}
for end < len(toml) && ((toml[end] >= '0' && toml[end] <= '9') || toml[end] == '.' || toml[end] == 'e' || toml[end] == 'E' || toml[end] == '+' || toml[end] == '-') {
end++
for end < len(toml) {
c := toml[end]
if (c >= '0' && c <= '9') || c == '.' || c == 'e' || c == 'E' {
end++
} else if (c == '+' || c == '-') && end > 0 && (toml[end-1] == 'e' || toml[end-1] == 'E') {
// Only allow + or - immediately after 'e' or 'E' for scientific notation
end++
} else {
break
}
}
result.WriteString(numberColor(toml[i:end]))
i = end