diff --git a/python/ycm/completers/cs/cs_completer.py b/python/ycm/completers/cs/cs_completer.py index 03c51566..68af3304 100755 --- a/python/ycm/completers/cs/cs_completer.py +++ b/python/ycm/completers/cs/cs_completer.py @@ -69,6 +69,7 @@ class CsharpCompleter( Completer ): 'StopServer', 'RestartServer', 'ServerRunning', + 'ServerReady', 'GoToDefinition', 'GoToDeclaration', 'GoToDefinitionElseDeclaration' ] @@ -95,6 +96,8 @@ class CsharpCompleter( Completer ): return self._StartServer( request_data ) elif command == 'ServerRunning': return self._ServerIsRunning() + elif command == 'ServerReady': + return self._ServerIsReady() elif command in [ 'GoToDefinition', 'GoToDeclaration', 'GoToDefinitionElseDeclaration' ]: @@ -221,6 +224,15 @@ class CsharpCompleter( Completer ): return False + def _ServerIsReady( self ): + """ Check if our OmniSharp server is ready """ + try: + return bool( self._omnisharp_port and + self._GetResponse( '/checkreadystatus', silent = True ) ) + except: + return False + + def _ServerLocation( self ): return 'http://localhost:' + str( self._omnisharp_port ) diff --git a/python/ycm/server/tests/get_completions_test.py b/python/ycm/server/tests/get_completions_test.py index 174ed03b..55e267d5 100644 --- a/python/ycm/server/tests/get_completions_test.py +++ b/python/ycm/server/tests/get_completions_test.py @@ -73,7 +73,7 @@ def GetCompletions_CsCompleter_Works_test(): while True: result = app.post_json( '/run_completer_command', BuildRequest( completer_target = 'filetype_default', - command_arguments = ['ServerRunning'], + command_arguments = ['ServerReady'], filetype = 'cs' ) ).json if result: break