-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
clang-format option InsertNewlineAtEOF does not add newline #63150
Comments
@llvm/issue-subscribers-clang-format |
InsertNewlineAtEOF inserts a newline only if the input doesn't end with one:
It seems that clang-format always removes empty lines at the end of the input. Please file another issue if you believe it shouldn't. |
Adds an option KeepEmptyLinesAtEOF to keep empty lines (up to MaxEmptyLinesToKeep) before EOF. This remedies the probably unintentional change in behavior introduced in 3d3ea84, which started to always remove empty lines before EOF. Fixes #56054. Fixes #63150. Differential Revision: https://reviews.llvm.org/D152305
On Fedora 36, running a local build from source of LLVM 16.0.4
The clang format option
InsertNewlineAtEOF : true
is not being applied, instead the newline is being removed:This also happens in our codebase, where we leverage .clang-format files to auto-format sections of our repo:
One counter-point that I can't explain, is that clang-format does format properly when using plugins in VS Code and vim.
For vim, I'm using the vim-clang-format plugin, with the following in
.vimrc
:If I open a file and save it with vim, it formats the file correctly including adding the newline at EOF.
The text was updated successfully, but these errors were encountered: