Skip to content

Commit c1e6cf8

Browse files
Fix extra newline from nimpretty when used with --stdin (#24951)
Using `echo` to print file contents to stdout automatically adds a newline at the end of the file contents. When using nimpretty to auto format files on save in some editors which replace the file contents with the formatted ones this means that with every save/format operation an additional newline is added to the end of the file. Using `stdout.write` does not automatically add a newline at the end preventing this issue. Fixes #24950
1 parent 091fb50 commit c1e6cf8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

nimpretty/nimpretty.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ proc handleStdinInput(opt: PrettyOptions) =
111111

112112
prettyPrint(path, path, opt)
113113

114-
echo(readAll(cfile))
114+
stdout.write(readAll(cfile))
115115

116116
close(cfile)
117117
removeFile(path)

0 commit comments

Comments
 (0)