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:
parent
8f34e92c05
commit
59463663e5
1 changed files with 7 additions and 0 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue