Skip to content

Commit 4a3385d

Browse files
smirashanduur
authored andcommitted
fix: undo CRLF on Windows (talosctl edit)
Fixes #12664 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com> (cherry picked from commit 410d8cb)
1 parent a842775 commit 4a3385d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cmd/talosctl/cmd/talos/edit.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ func editFn(c *client.Client) func(context.Context, string, resource.Resource, e
156156
}
157157

158158
func stripEditingComment(in []byte) []byte {
159+
// Note: on Windows, we use crlf.NewCRLFWriter which converts LF to CRLF before opening the editor.
160+
// So this code block below undoes that conversion back to LF for consistent processing.
161+
if runtime.GOOS == "windows" {
162+
// revert back CRLF to LF for processing
163+
in = bytes.ReplaceAll(in, []byte("\r\n"), []byte("\n"))
164+
}
165+
159166
for {
160167
idx := bytes.Index(in, []byte{'\n'})
161168
if idx == -1 {

0 commit comments

Comments
 (0)