diff options
author | Hans Wennborg <hans@hanshq.net> | 2017-09-22 21:47:39 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2017-09-22 21:47:39 +0000 |
commit | 978419bf37546da788a7042d8de4044196c1d515 (patch) | |
tree | e239812b7eee984750f1f8fde86dc5fb969d862c | |
parent | ea927baee2ab71dde4b4c8f4df5c565ea2ff9f2b (diff) | |
download | bcm5719-llvm-978419bf37546da788a7042d8de4044196c1d515.tar.gz bcm5719-llvm-978419bf37546da788a7042d8de4044196c1d515.zip |
clang-format plugin: Add missing NL (new line) at EOF (end of file)
clang-format.exe removes trailing new lines at end of file.
However, if no NL is found at EOF one should be added.
Patch by Teodor MICU!
Differential Revision: https://reviews.llvm.org/D37732
llvm-svn: 314033
-rw-r--r-- | clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs b/clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs index d16d6d50414..efb2147f2b4 100644 --- a/clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs +++ b/clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs @@ -326,7 +326,13 @@ namespace LLVM.ClangFormat string filePath = Vsix.GetDocumentPath(view);
var path = Path.GetDirectoryName(filePath);
+
string text = view.TextBuffer.CurrentSnapshot.GetText();
+ if (!text.EndsWith(Environment.NewLine))
+ {
+ view.TextBuffer.Insert(view.TextBuffer.CurrentSnapshot.Length, Environment.NewLine);
+ text += Environment.NewLine;
+ }
RunClangFormatAndApplyReplacements(text, 0, text.Length, path, filePath, options, view);
}
|