]> granicus.if.org Git - clang/commitdiff
Use -lines option instead of -offset/-length. This fixes problems with files using...
authorAlexander Kornienko <alexfh@google.com>
Sat, 20 Jul 2013 01:01:25 +0000 (01:01 +0000)
committerAlexander Kornienko <alexfh@google.com>
Sat, 20 Jul 2013 01:01:25 +0000 (01:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186740 91177308-0d34-0410-b5e6-96231b3b80d8

tools/clang-format/clang-format.py

index 29be72e176b675b0333c96e34eb97efcaf085a9a..866baf50f104f166b2949c2cbd3aed7ca9ab4f10 100644 (file)
@@ -35,10 +35,7 @@ text = '\n'.join(buf)
 
 # Determine range to format.
 cursor = int(vim.eval('line2byte(line("."))+col(".")')) - 2
-offset = int(vim.eval('line2byte(' +
-                      str(vim.current.range.start + 1) + ')')) - 1
-length = int(vim.eval('line2byte(' +
-                      str(vim.current.range.end + 2) + ')')) - offset - 2
+lines = '%s:%s' % (vim.current.range.start + 1, vim.current.range.end + 1)
 
 # Avoid flashing an ugly, ugly cmd prompt on Windows when invoking clang-format.
 startupinfo = None
@@ -48,8 +45,8 @@ if sys.platform.startswith('win32'):
   startupinfo.wShowWindow = subprocess.SW_HIDE
 
 # Call formatter.
-p = subprocess.Popen([binary, '-offset', str(offset), '-length', str(length),
-                      '-style', style, '-cursor', str(cursor)],
+p = subprocess.Popen([binary, '-lines', lines, '-style', style,
+                      '-cursor', str(cursor)],
                      stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                      stdin=subprocess.PIPE, startupinfo=startupinfo)
 stdout, stderr = p.communicate(input=text)