fix(config): restore CRLF normalization lost by the split-based unset rewrite

Base commentOutYamlKey scanned with bufio.Scanner, whose ScanLines drops a
trailing \r, so CRLF files came back LF-only. The PR switched to
strings.Split to preserve the file final newline, which carried every \r
through. Normalizing at entry keeps both properties: base own
TestCommentOutYamlKeyPreservesTheTrailingNewline now passes 9/9.
This commit is contained in:
Gas City Adopt-PR 2026-09-28 11:19:07 +00:00
commit 59463663e5

View file

@ -1095,6 +1095,13 @@ func scalarStyleFor(value string) yaml.Style {
}
func commentOutYamlKey(content, key string) (string, error) {
// Normalize CRLF up front. The old implementation scanned with
// bufio.Scanner, whose ScanLines drops a trailing "\r", so a CRLF file came
// back LF-only; splitting on "\n" instead (below, to keep the file's final
// newline) would otherwise carry every "\r" through and change that
// long-standing behavior.
content = strings.ReplaceAll(content, "\r\n", "\n")
if err := unsupportedUnsetShape(content, key); err != nil {
return "", err
}