Skip to content

Commit

Permalink
bugfix in solutionfile detector
Browse files Browse the repository at this point in the history
  • Loading branch information
chtenb committed Jun 29, 2013
1 parent faa6cf3 commit e453c2b
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions python/ycm/completers/cs/cs_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,31 @@ def OnUserCommand( self, arguments ):
def _StartServer( self ):
""" Start the OmniSharp server """
if ( not self._ServerIsRunning() ):
# Find the solution file
folder = os.path.dirname( vim.current.buffer.name )
solutionfiles = glob.glob1( folder, '*.sln' )
while not solutionfiles:
lastfolder = folder
# Traverse up a level
folder = os.path.dirname( folder )
if folder == lastfolder:
break
solutionfiles = glob.glob1( folder, '*.sln' )

if len( solutionfiles ) == 1:
omnisharp = os.path.join( os.path.abspath( os.path.dirname( __file__ ) ), './OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' )
solutionfile = os.path.abspath ( solutionfiles[0] )
if len( solutionfiles ) == 0:
vimsupport.PostVimMessage( 'Error starting OmniSharp server: no solutionfile found' )
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 )
else:
vimsupport.PostVimMessage( 'Error starting OmniSharp server: none or multiple solutionfiles are found' )
vimsupport.PostVimMessage( 'Error starting OmniSharp server: multiple solutionfiles found' )

def _StopServer( self ):
""" Stop the OmniSharp server """
Expand Down Expand Up @@ -120,5 +124,5 @@ def _GetResponse( self, endPoint, parameters={} ):
response = urllib2.urlopen( target, parameters )
return json.loads( response.read() )
except Exception as e:
#vimsupport.PostVimMessage('OmniSharp : Could not connect to ' + target + ': ' + str(e))
vimsupport.PostVimMessage('OmniSharp : Could not connect to ' + target + ': ' + str(e))
return None

0 comments on commit e453c2b

Please sign in to comment.