r209417 - clang-format: Fix vim-integration for empty files.
Daniel Jasper
djasper at google.com
Thu May 22 04:37:05 PDT 2014
Author: djasper
Date: Thu May 22 06:37:05 2014
New Revision: 209417
URL: http://llvm.org/viewvc/llvm-project?rev=209417&view=rev
Log:
clang-format: Fix vim-integration for empty files.
Discovered by Ahmed Charles in http://reviews.llvm.org/D3018.
Modified:
cfe/trunk/tools/clang-format/clang-format.py
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=209417&r1=209416&r2=209417&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/clang-format.py (original)
+++ cfe/trunk/tools/clang-format/clang-format.py Thu May 22 06:37:05 2014
@@ -38,9 +38,14 @@ def main():
text = '\n'.join(buf)
# Determine range to format.
- cursor = int(vim.eval('line2byte(line("."))+col(".")')) - 2
lines = '%s:%s' % (vim.current.range.start + 1, vim.current.range.end + 1)
+ # Determine the cursor position.
+ cursor = int(vim.eval('line2byte(line("."))+col(".")')) - 2
+ if cursor < 0:
+ print 'Couldn\'t determine cursor position. Is your file empty?'
+ return
+
# Avoid flashing an ugly, ugly cmd prompt on Windows when invoking clang-format.
startupinfo = None
if sys.platform.startswith('win32'):
More information about the cfe-commits
mailing list