Skip to content

Commit 978419b

Browse files
committed
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
1 parent ea927ba commit 978419b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,13 @@ private void FormatView(IWpfTextView view, OptionPageGrid options)
326326

327327
string filePath = Vsix.GetDocumentPath(view);
328328
var path = Path.GetDirectoryName(filePath);
329+
329330
string text = view.TextBuffer.CurrentSnapshot.GetText();
331+
if (!text.EndsWith(Environment.NewLine))
332+
{
333+
view.TextBuffer.Insert(view.TextBuffer.CurrentSnapshot.Length, Environment.NewLine);
334+
text += Environment.NewLine;
335+
}
330336

331337
RunClangFormatAndApplyReplacements(text, 0, text.Length, path, filePath, options, view);
332338
}

0 commit comments

Comments
 (0)