From da095cb93b456525cb307344ffc9d991913056f6 Mon Sep 17 00:00:00 2001 From: micbou Date: Sat, 2 Jan 2016 20:21:20 +0100 Subject: [PATCH 1/2] Update notifications when ycmd server crashed Tell the user to run the YcmToggleLogs command if the server crashed. --- python/ycm/youcompleteme.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/python/ycm/youcompleteme.py b/python/ycm/youcompleteme.py index 6e86646f..64be17cf 100644 --- a/python/ycm/youcompleteme.py +++ b/python/ycm/youcompleteme.py @@ -69,17 +69,13 @@ PatchNoProxy() signal.signal( signal.SIGINT, signal.SIG_IGN ) HMAC_SECRET_LENGTH = 16 -NUM_YCMD_STDERR_LINES_ON_CRASH = 30 +SERVER_CRASH_MESSAGE_STDERR_FILE = ( + 'The ycmd server SHUT DOWN (restart with :YcmRestartServer). ' + 'Run :YcmToggleLogs stderr to check the logs.' ) SERVER_CRASH_MESSAGE_STDERR_FILE_DELETED = ( 'The ycmd server SHUT DOWN (restart with :YcmRestartServer). ' 'Logfile was deleted; set g:ycm_server_keep_logfiles to see errors ' 'in the future.' ) -SERVER_CRASH_MESSAGE_STDERR_FILE = ( - 'The ycmd server SHUT DOWN (restart with :YcmRestartServer). ' + - 'Stderr (last {0} lines):\n\n'.format( NUM_YCMD_STDERR_LINES_ON_CRASH ) ) -SERVER_CRASH_MESSAGE_SAME_STDERR = ( - 'The ycmd server SHUT DOWN (restart with :YcmRestartServer). ' - ' check console output for logs!' ) SERVER_IDLE_SUICIDE_SECONDS = 10800 # 3 hours @@ -151,17 +147,11 @@ class YouCompleteMe( object ): if self._user_notified_about_crash or self.IsServerAlive(): return self._user_notified_about_crash = True - if self._server_stderr: - try: - with open( self._server_stderr, 'r' ) as server_stderr_file: - error_output = ''.join( server_stderr_file.readlines()[ - : - NUM_YCMD_STDERR_LINES_ON_CRASH ] ) - vimsupport.PostMultiLineNotice( SERVER_CRASH_MESSAGE_STDERR_FILE + - error_output ) - except IOError: - vimsupport.PostVimMessage( SERVER_CRASH_MESSAGE_STDERR_FILE_DELETED ) - else: - vimsupport.PostVimMessage( SERVER_CRASH_MESSAGE_SAME_STDERR ) + try: + vimsupport.CheckFilename( self._server_stderr ) + vimsupport.PostVimMessage( SERVER_CRASH_MESSAGE_STDERR_FILE ) + except RuntimeError: + vimsupport.PostVimMessage( SERVER_CRASH_MESSAGE_STDERR_FILE_DELETED ) def ServerPid( self ): From 7fda494026b081d1f4e7b0e8ed43b10baf5492f2 Mon Sep 17 00:00:00 2001 From: micbou Date: Sun, 3 Jan 2016 12:13:00 +0100 Subject: [PATCH 2/2] Add quotes in notifications Add quotes for Vim commands and options in notifications. --- python/ycm/youcompleteme.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/python/ycm/youcompleteme.py b/python/ycm/youcompleteme.py index 64be17cf..159dba26 100644 --- a/python/ycm/youcompleteme.py +++ b/python/ycm/youcompleteme.py @@ -70,12 +70,12 @@ signal.signal( signal.SIGINT, signal.SIG_IGN ) HMAC_SECRET_LENGTH = 16 SERVER_CRASH_MESSAGE_STDERR_FILE = ( - 'The ycmd server SHUT DOWN (restart with :YcmRestartServer). ' - 'Run :YcmToggleLogs stderr to check the logs.' ) + "The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). " + "Run ':YcmToggleLogs stderr' to check the logs." ) SERVER_CRASH_MESSAGE_STDERR_FILE_DELETED = ( - 'The ycmd server SHUT DOWN (restart with :YcmRestartServer). ' - 'Logfile was deleted; set g:ycm_server_keep_logfiles to see errors ' - 'in the future.' ) + "The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). " + "Logfile was deleted; set 'g:ycm_server_keep_logfiles' to see errors " + "in the future." ) SERVER_IDLE_SUICIDE_SECONDS = 10800 # 3 hours