[clang-include-fixer] Suppress cmd prompt from Vim on Windows
authorReid Kleckner <rnk@google.com>
Mon, 18 Nov 2019 23:15:10 +0000 (15:15 -0800)
committerReid Kleckner <rnk@google.com>
Fri, 22 Nov 2019 19:28:42 +0000 (11:28 -0800)
Copied from the clang-format.py editor integration.

Reviewers: bkramer

Differential Revision: https://reviews.llvm.org/D70518

clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py

index 4c38f71..df05101 100644 (file)
@@ -85,9 +85,16 @@ def GetUserSelection(message, headers, maximum_suggested_headers):
 
 
 def execute(command, text):
+  # Avoid flashing a cmd prompt on Windows.
+  startupinfo = None
+  if sys.platform.startswith('win32'):
+    startupinfo = subprocess.STARTUPINFO()
+    startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
+    startupinfo.wShowWindow = subprocess.SW_HIDE
+
   p = subprocess.Popen(command,
                        stdout=subprocess.PIPE, stderr=subprocess.PIPE,
-                       stdin=subprocess.PIPE)
+                       stdin=subprocess.PIPE, startupinfo=startupinfo)
   return p.communicate(input=text)