Add test for string escape bug and implement fix

Co-authored-by: mikefarah <1151925+mikefarah@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-20 15:55:17 +11:00
committed by Mike Farah
co-authored by mikefarah
parent b7cbe59fd7
commit 7f60daad20
2 changed files with 74 additions and 3 deletions
+8 -3
View File
@@ -614,9 +614,14 @@ func (te *tomlEncoder) colorizeToml(input []byte) []byte {
if ch == '"' || ch == '\'' {
quote := ch
end := i + 1
for end < len(toml) && toml[end] != quote {
if toml[end] == '\\' {
end++ // skip escaped char
for end < len(toml) {
if toml[end] == quote {
break
}
if toml[end] == '\\' && end+1 < len(toml) {
// Skip the backslash and the escaped character
end += 2
continue
}
end++
}