From 2743f9652973094995688adadd4cfec76401f4a8 Mon Sep 17 00:00:00 2001 From: Chiel92 Date: Sun, 7 Jul 2013 13:06:07 +0200 Subject: [PATCH] Starting subprocess is working now --- python/ycm/completers/cs/cs_completer.py | 26 ++++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/python/ycm/completers/cs/cs_completer.py b/python/ycm/completers/cs/cs_completer.py index 58e92389..0b34cef3 100755 --- a/python/ycm/completers/cs/cs_completer.py +++ b/python/ycm/completers/cs/cs_completer.py @@ -80,20 +80,24 @@ class CsharpCompleter( ThreadedCompleter ): if len( solutionfiles ) == 0: vimsupport.PostVimMessage( 'Error starting OmniSharp server: no solutionfile found' ) + return elif len( solutionfiles ) == 1: - omnisharp = os.path.join( os.path.abspath( os.path.dirname( __file__ ) ), - 'OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' ) - solutionfile = os.path.join ( folder, solutionfiles[0] ) - command = [ omnisharp, '-p ' + str( self.OmniSharpPort ), '-s ' + solutionfile ] - - vimsupport.PostVimMessage( 'starting server... ' + ' '.join( command ) ) - - # Why doesn't this work properly? - # When starting manually in seperate console, everything works - # Maybe due to bothering stdin/stdout redirecting? - subprocess.Popen( command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) + solutionfile = solutionfiles[0] else: + # This still has to be caught by giving the user a choice vimsupport.PostVimMessage( 'Error starting OmniSharp server: multiple solutionfiles found' ) + return + + omnisharp = os.path.join( os.path.abspath( os.path.dirname( __file__ ) ), + 'OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' ) + solutionfile = os.path.join ( folder, solutionfile ) + # command has to be provided as one string + command = [ omnisharp + ' -p ' + str( self.OmniSharpPort ) + ' -s ' + solutionfile ] + + vimsupport.PostVimMessage( 'starting server...\n' + ' '.join( command ) ) + + with open(os.devnull, "w") as fnull: + result = subprocess.Popen(command, stdout = fnull, stderr = fnull, shell=True) def _StopServer( self ): """ Stop the OmniSharp server """