From 4626a20b2d46a3a8ea17d265dff220c5a02700d8 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 22 Jul 2013 16:22:13 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186840 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/clang-format/clang-format.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/clang-format/clang-format.py b/tools/clang-format/clang-format.py index bf84ed0f5c..1d27985ea0 100644 --- a/tools/clang-format/clang-format.py +++ b/tools/clang-format/clang-format.py @@ -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)) -- 2.40.0