From 59463663e561f2155fb4be9678fe325f7873cd8d Mon Sep 17 00:00:00 2001 From: Gas City Adopt-PR Date: Mon, 28 Sep 2026 11:19:07 +0000 Subject: [PATCH] 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. --- internal/config/yaml_config.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/config/yaml_config.go b/internal/config/yaml_config.go index a851123c2..643deeab1 100644 --- a/internal/config/yaml_config.go +++ b/internal/config/yaml_config.go @@ -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 }