bugfix in solutionfile detector
This commit is contained in:
parent
faa6cf3f36
commit
e453c2b772
@ -69,27 +69,31 @@ class CsharpCompleter( ThreadedCompleter ):
|
|||||||
def _StartServer( self ):
|
def _StartServer( self ):
|
||||||
""" Start the OmniSharp server """
|
""" Start the OmniSharp server """
|
||||||
if ( not self._ServerIsRunning() ):
|
if ( not self._ServerIsRunning() ):
|
||||||
# Find the solution file
|
|
||||||
folder = os.path.dirname( vim.current.buffer.name )
|
folder = os.path.dirname( vim.current.buffer.name )
|
||||||
solutionfiles = glob.glob1( folder, '*.sln' )
|
solutionfiles = glob.glob1( folder, '*.sln' )
|
||||||
while not solutionfiles:
|
while not solutionfiles:
|
||||||
lastfolder = folder
|
lastfolder = folder
|
||||||
# Traverse up a level
|
|
||||||
folder = os.path.dirname( folder )
|
folder = os.path.dirname( folder )
|
||||||
if folder == lastfolder:
|
if folder == lastfolder:
|
||||||
break
|
break
|
||||||
solutionfiles = glob.glob1( folder, '*.sln' )
|
solutionfiles = glob.glob1( folder, '*.sln' )
|
||||||
|
|
||||||
if len( solutionfiles ) == 1:
|
if len( solutionfiles ) == 0:
|
||||||
omnisharp = os.path.join( os.path.abspath( os.path.dirname( __file__ ) ), './OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' )
|
vimsupport.PostVimMessage( 'Error starting OmniSharp server: no solutionfile found' )
|
||||||
solutionfile = os.path.abspath ( solutionfiles[0] )
|
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 ]
|
command = [ omnisharp, '-p ' + str( self.OmniSharpPort ), '-s ' + solutionfile ]
|
||||||
|
|
||||||
|
vimsupport.PostVimMessage( 'starting server... ' + ' '.join( command ) )
|
||||||
|
|
||||||
# Why doesn't this work properly?
|
# Why doesn't this work properly?
|
||||||
# When starting manually in seperate console, everything works
|
# When starting manually in seperate console, everything works
|
||||||
# Maybe due to bothering stdin/stdout redirecting?
|
# Maybe due to bothering stdin/stdout redirecting?
|
||||||
subprocess.Popen( command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
|
subprocess.Popen( command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
|
||||||
else:
|
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 ):
|
def _StopServer( self ):
|
||||||
""" Stop the OmniSharp server """
|
""" Stop the OmniSharp server """
|
||||||
@ -120,5 +124,5 @@ class CsharpCompleter( ThreadedCompleter ):
|
|||||||
response = urllib2.urlopen( target, parameters )
|
response = urllib2.urlopen( target, parameters )
|
||||||
return json.loads( response.read() )
|
return json.loads( response.read() )
|
||||||
except Exception as e:
|
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
|
return None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user