-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unwanted \n
at the end of file when using eol
#781
Comments
\n
at the end of file on Windows when using eol = "\r\n"
\n
at the end of file when using eol
I can confirm some of this behavior as well with the 1.5.10 version. If I set eol to \r\n |
@gabrielmaldi @Deklin |
@bitwiseman just tried this in v1.8.0 and it doesn't seem to be fixed. Input (no newline at eof): var a = 1; Hex: Running the beautifier with Output: var a = 1;
Hex: So it's adding two new lines (in macOS). If the input already ends with a new line, it adds another new line anyway. If I use Haven't tried in Windows but I assume it's the same behavior. Thanks! |
@gabrielmaldi What is the command you are using to run this? |
I was running the beautifier through Just running the beautifier by itself works fine! |
v1.5.10
, witheol = "\n"
on OS X, or witheol = "\r\n"
on Windows, adds an unwanted\n
at the end of the file.\r
from the last newline, see below.jsbeautifier
,HTML
files are not affected.Given a file using
\r\n
as newline:Which expressed in hex is:
eol = "\r\n"
adds a\n
(0A
) at the end of the file:end_with_newline = true
it does add the new line as it should but it also adds the same\n
after it:If the original file already ends with newline:
eol = "\r\n"
yields:So it's removing the
\r
(0D
) in the last newline.end_with_newline = true
adds the\n
at the end:Update: all of the above (except the case where
\r
is removed) also happens on OS X with a file using\n
as newline.To sum up:
end_with_newline = false
end_with_newline = true
\r\n
\n
at the end\n
at the end\r\n
\r
from last newline\n
at the endThe text was updated successfully, but these errors were encountered: