Index: clang/tools/clang-format/clang-format.py =================================================================== --- clang/tools/clang-format/clang-format.py +++ clang/tools/clang-format/clang-format.py @@ -70,7 +70,7 @@ # Get the current text. encoding = vim.eval("&encoding") buf = get_buffer(encoding) - text = '\n'.join(buf) + text = '\n'.join(buf) + '\n' # Determine range to format. if vim.eval('exists("l:lines")') == '1': @@ -129,7 +129,7 @@ else: lines = stdout.decode(encoding).split('\n') output = json.loads(lines[0]) - lines = lines[1:] + lines = lines[1:-1] sequence = difflib.SequenceMatcher(None, buf, lines) for op in reversed(sequence.get_opcodes()): if op[0] is not 'equal':