r186840 - Fix bug in clang-format's vim integration cause by r186789.

Daniel Jasper djasper at google.com
Mon Jul 22 09:22:14 PDT 2013

Author: djasper
Date: Mon Jul 22 11:22:13 2013
New Revision: 186840

URL: http://llvm.org/viewvc/llvm-project?rev=186840&view=rev
Fix bug in clang-format's vim integration cause by r186789.

After the first operation, the buffer contents has changed and thus all
other operations would be invalid. Executing the operations in reversed
order should fix this.


Modified: cfe/trunk/tools/clang-format/clang-format.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.py?rev=186840&r1=186839&r2=186840&view=diff
--- cfe/trunk/tools/clang-format/clang-format.py (original)
+++ cfe/trunk/tools/clang-format/clang-format.py Mon Jul 22 11:22:13 2013
@@ -69,7 +69,7 @@ else:
   output = json.loads(lines[0])
   lines = lines[1:]
   sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
-  for op in sequence.get_opcodes():
+  for op in reversed(sequence.get_opcodes()):
     if op[0] is not 'equal':
       vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
   vim.command('goto %d' % (output['Cursor'] + 1))

More information about the cfe-commits mailing list