clang-format.exe removes trailing new lines at end of file.
However, if no NL is found at EOF one should be added.
Let me know if you prefer this to be optional. Other Visual Studio extensions have this functionality configurable.
Differential D37732
Add missing NL (new line) at EOF (end of file) mteodor on Sep 12 2017, 1:46 AM. Authored by
Details clang-format.exe removes trailing new lines at end of file. However, if no NL is found at EOF one should be added. Let me know if you prefer this to be optional. Other Visual Studio extensions have this functionality configurable.
Diff Detail
Event TimelineComment Actions (Meta comment: please upload patches with more context so the rest of the files show up in the review. If you generate the patch with diff or git diff, do it by passing along -U9999.) I don't know much about VS, but doesn't it already have an option to save files with newline at end of file? If we want clang-format to do this, should it perhaps be part of clang-format.exe itself, rather than the plugin? Comment Actions Unfortunately, it doesn't have this option.
That would be even better. However, since this is practically a Windows only problem I don't have many hopes. In Linux/UNIX world, the POSIX requirement for LINE termination is implemented virtually by all text editors. Some don't even have an option to do otherwise. Comment Actions OK, I suppose that's a good case for donig this in the plugin. I wonder if we'll need to expose this as a plugin option though, in case some users (for weird reasons, but some people seem to like it that way) don't want newline at the end of the file..
Comment Actions We could add it later if requested. However, in my experience with this issue the response from other devs was: I don't care about this!. Thus, this is only an editor problem so that we don't have to deal with it manually. No arguments against it. Comment Actions This looks good to me. Do you have commit access, or would you like me to commit for you? Thanks! Fair enough. Comment Actions For what it's worth, I think it'd also be fine to always add a newline at the end of a file in clang-format, or have an option. I think this is fine, too, though. Comment Actions FWIW, I would be happy to have this in clang-format itself. With a few coders working on a few editors on different platforms, missing lines at EOF are likely to sneak in occasionally, requiring cleanup commits. |