diff options
author | Reid Kleckner <reid@kleckner.net> | 2013-06-10 14:16:26 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2013-06-10 14:16:26 +0000 |
commit | 57e68474b1879ca06360adc6eaf8d547ab0dd157 (patch) | |
tree | c6861d52e08f5deb274787ffef69b0db4c010294 /tools/clang-format | |
parent | 03a83238c39e290ed6e2ced7663efa9fa8c19158 (diff) | |
download | clang-57e68474b1879ca06360adc6eaf8d547ab0dd157.tar.gz clang-57e68474b1879ca06360adc6eaf8d547ab0dd157.tar.bz2 clang-57e68474b1879ca06360adc6eaf8d547ab0dd157.tar.xz |
[clang-format] Don't flash an ugly cmd prompt in Vim on Windows
Reviewers: klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D941
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183654 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/clang-format')
-rw-r--r-- | tools/clang-format/clang-format.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/clang-format/clang-format.py b/tools/clang-format/clang-format.py index bc47fcbb7d..60e2e55028 100644 --- a/tools/clang-format/clang-format.py +++ b/tools/clang-format/clang-format.py @@ -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. |