Improve server crash notification at startup

Notify the user if the server crashed during server polling at startup.
This commit is contained in:
micbou 2017-09-23 16:37:24 +02:00
parent b5c8e57962
commit 2b8e86797c
No known key found for this signature in database
GPG Key ID: C7E8FD1F3BDA1E05
3 changed files with 4 additions and 5 deletions

View File

@ -487,6 +487,7 @@ endfunction
function! s:PollServerReady( timer_id ) function! s:PollServerReady( timer_id )
if !s:Pyeval( 'ycm_state.IsServerAlive()' ) if !s:Pyeval( 'ycm_state.IsServerAlive()' )
exec s:python_command "ycm_state.NotifyUserIfServerCrashed()"
" Server crashed. Don't poll it again. " Server crashed. Don't poll it again.
return return
endif endif

View File

@ -108,7 +108,7 @@ def RunNotifyUserIfServerCrashed( ycm, test, post_vim_message ):
ycm._server_popen = MagicMock( autospec = True ) ycm._server_popen = MagicMock( autospec = True )
ycm._server_popen.poll.return_value = test[ 'return_code' ] ycm._server_popen.poll.return_value = test[ 'return_code' ]
ycm._NotifyUserIfServerCrashed() ycm.OnFileReadyToParse()
assert_that( ycm._logger.error.call_args[ 0 ][ 0 ], assert_that( ycm._logger.error.call_args[ 0 ][ 0 ],
test[ 'expected_message' ] ) test[ 'expected_message' ] )

View File

@ -186,8 +186,6 @@ class YouCompleteMe( object ):
self._server_popen = utils.SafePopen( args, stdin_windows = PIPE, self._server_popen = utils.SafePopen( args, stdin_windows = PIPE,
stdout = PIPE, stderr = PIPE ) stdout = PIPE, stderr = PIPE )
self._NotifyUserIfServerCrashed()
def _SetupLogging( self ): def _SetupLogging( self ):
def FreeFileFromOtherProcesses( file_object ): def FreeFileFromOtherProcesses( file_object ):
@ -244,7 +242,7 @@ class YouCompleteMe( object ):
return self._server_is_ready_with_cache return self._server_is_ready_with_cache
def _NotifyUserIfServerCrashed( self ): def NotifyUserIfServerCrashed( self ):
if ( not self._server_popen or self._user_notified_about_crash or if ( not self._server_popen or self._user_notified_about_crash or
self.IsServerAlive() ): self.IsServerAlive() ):
return return
@ -371,7 +369,7 @@ class YouCompleteMe( object ):
def OnFileReadyToParse( self ): def OnFileReadyToParse( self ):
if not self.IsServerAlive(): if not self.IsServerAlive():
self._NotifyUserIfServerCrashed() self.NotifyUserIfServerCrashed()
return return
if not self.IsServerReady(): if not self.IsServerReady():