From fd6338fa88f4b7111fbad1e31da74681bfb5e7ab Mon Sep 17 00:00:00 2001 From: nop Date: Tue, 10 Dec 2013 12:46:05 +0100 Subject: [PATCH] Fixed OmniSharp launch under Windows (again) We pass shell=True to Popen so that OmniSharp is not started inside a new visible window under Windows. And since we use shell=True, we pass the command to execute as a string, as recommended by Python's docs (also, it won't work when passed as a sequence anyway :) ). --- python/ycm/completers/cs/cs_completer.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/python/ycm/completers/cs/cs_completer.py b/python/ycm/completers/cs/cs_completer.py index fe5eff5a..9e1e4eaf 100755 --- a/python/ycm/completers/cs/cs_completer.py +++ b/python/ycm/completers/cs/cs_completer.py @@ -151,11 +151,13 @@ class CsharpCompleter( Completer ): raise RuntimeError( SERVER_NOT_FOUND_MSG.format( omnisharp ) ) path_to_solutionfile = os.path.join( folder, solutionfile ) - command = [ omnisharp, '-p', str( self._omnisharp_port ), '-s', - path_to_solutionfile ] + # we need to pass the command to Popen as a string since we're passing + # shell=True (as recommended by Python's doc) + command = omnisharp + ' -p ' + str( self._omnisharp_port ) + ' -s ' + \ + path_to_solutionfile if not utils.OnWindows(): - command.insert(0, 'mono') + command = 'mono ' + command filename_format = os.path.join( utils.PathToTempDir(), 'omnisharp_{port}_{sln}_{std}.log' ) @@ -167,7 +169,9 @@ class CsharpCompleter( Completer ): with open( self._filename_stderr, 'w' ) as fstderr: with open( self._filename_stdout, 'w' ) as fstdout: - subprocess.Popen( command, stdout=fstdout, stderr=fstderr ) + # shell=True is needed for Windows so OmniSharp does not spawn + # in a new visible window + subprocess.Popen( command, stdout=fstdout, stderr=fstderr, shell=True ) self._logger.info( 'Starting OmniSharp server' )