r183654 - [clang-format] Don't flash an ugly cmd prompt in Vim on Windows
Reid Kleckner
reid at kleckner.net
Mon Jun 10 07:16:26 PDT 2013
Author: rnk
Date: Mon Jun 10 09:16:26 2013
New Revision: 183654
URL: http://llvm.org/viewvc/llvm-project?rev=183654&view=rev
Log:
[clang-format] Don't flash an ugly cmd prompt in Vim on Windows
Reviewers: klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D941
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=183654&r1=183653&r2=183654&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/clang-format.py (original)
+++ cfe/trunk/tools/clang-format/clang-format.py Mon Jun 10 09:16:26 2013
@@ -19,6 +19,7 @@
import json
import subprocess
+import sys
import vim
# Change this to the full path if clang-format is not on the path.
@@ -39,11 +40,18 @@ offset = int(vim.eval('line2byte(' +
length = int(vim.eval('line2byte(' +
str(vim.current.range.end + 2) + ')')) - offset - 2
+# Avoid flashing an ugly, ugly cmd prompt on Windows when invoking clang-format.
+startupinfo = None
+if sys.platform.startswith('win32'):
+ startupinfo = subprocess.STARTUPINFO()
+ startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
+ startupinfo.wShowWindow = subprocess.SW_HIDE
+
# Call formatter.
p = subprocess.Popen([binary, '-offset', str(offset), '-length', str(length),
'-style', style, '-cursor', str(cursor)],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
- stdin=subprocess.PIPE)
+ stdin=subprocess.PIPE, startupinfo=startupinfo)
stdout, stderr = p.communicate(input=text)
# If successful, replace buffer contents.
More information about the cfe-commits
mailing list