From aa0ccdb9251e57a3721ce1f4a0d338b80363b81d Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Mon, 4 Nov 2013 11:15:03 -0800 Subject: [PATCH] Better client notice when ycmd crashes Now we only show the last 30 lines of stderr instead of everything in it which was not very useful. We also tell the user about :YcmRestartServer. --- python/ycm/youcompleteme.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/python/ycm/youcompleteme.py b/python/ycm/youcompleteme.py index 7b96769c..f390a6c5 100644 --- a/python/ycm/youcompleteme.py +++ b/python/ycm/youcompleteme.py @@ -50,9 +50,13 @@ except ImportError: # https://github.com/kennethreitz/requests/issues/879 os.environ['no_proxy'] = '127.0.0.1,localhost' -SERVER_CRASH_MESSAGE_STDERR_FILE = 'The ycmd server SHUT DOWN with output:\n' +NUM_YCMD_STDERR_LINES_ON_CRASH = 30 +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, check console output for logs!' ) + 'The ycmd server SHUT DOWN (restart with :YcmRestartServer). ' + ' check console output for logs!' ) class YouCompleteMe( object ): @@ -114,8 +118,10 @@ class YouCompleteMe( object ): return if self._server_stderr: 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 + - server_stderr_file.read() ) + error_output ) else: vimsupport.PostVimMessage( SERVER_CRASH_MESSAGE_SAME_STDERR )