mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-01 22:44:50 +08:00
Fixing number color issue
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user