Auto merge of #2798 - micbou:improve-user-notification-startup, r=puremourning

[READY] Improve server crash notification at startup

Instead of notifying the user if the server crashed immediately after starting it (which is unlikely to work because the server process is necessarily up at this point), do it during polling.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2798)
<!-- Reviewable:end -->
This commit is contained in:
zzbot 2017-10-06 00:33:41 -07:00 committed by GitHub
commit 6f8fc43365
3 changed files with 4 additions and 5 deletions

View File

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

View File

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

View File

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