]> granicus.if.org Git - clang/commitdiff
clang-format plugin: Add missing NL (new line) at EOF (end of file)
authorHans Wennborg <hans@hanshq.net>
Fri, 22 Sep 2017 21:47:39 +0000 (21:47 +0000)
committerHans Wennborg <hans@hanshq.net>
Fri, 22 Sep 2017 21:47:39 +0000 (21:47 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314033 91177308-0d34-0410-b5e6-96231b3b80d8

tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs

index d16d6d5041473ae098f83b59c1b62611828397a3..efb2147f2b43be351426edd9e7b4a07c110e99e7 100644 (file)
@@ -326,7 +326,13 @@ namespace LLVM.ClangFormat
 \r
             string filePath = Vsix.GetDocumentPath(view);\r
             var path = Path.GetDirectoryName(filePath);\r
+\r
             string text = view.TextBuffer.CurrentSnapshot.GetText();\r
+            if (!text.EndsWith(Environment.NewLine))\r
+            {\r
+                view.TextBuffer.Insert(view.TextBuffer.CurrentSnapshot.Length, Environment.NewLine);\r
+                text += Environment.NewLine;\r
+            }\r
 \r
             RunClangFormatAndApplyReplacements(text, 0, text.Length, path, filePath, options, view);\r
         }\r