From 37f3f1530e13f022926194354ab35d27909c86e0 Mon Sep 17 00:00:00 2001 From: micbou Date: Sat, 28 Nov 2015 22:18:54 +0100 Subject: [PATCH] Handle scalar response from subcommands When the ycmd server returns a scalar (boolean, number, string, etc.) from a subcommand, print it to the user. --- python/ycm/client/command_request.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/python/ycm/client/command_request.py b/python/ycm/client/command_request.py index bd60d021..3a4b049a 100644 --- a/python/ycm/client/command_request.py +++ b/python/ycm/client/command_request.py @@ -63,15 +63,18 @@ class CommandRequest( BaseRequest ): if not self.Done() or self._response is None: return - if isinstance( self._response, bool ): - return self._HandleBooleanResponse() - if self._is_goto_command: return self._HandleGotoResponse() if self._is_fixit_command: return self._HandleFixitResponse() + # If not a dictionary or a list, the response is necessarily a + # scalar: boolean, number, string, etc. In this case, we print + # it to the user. + if not isinstance( self._response, ( dict, list ) ): + return self._HandleBasicResponse() + if 'message' in self._response: return self._HandleMessageResponse() @@ -103,10 +106,8 @@ class CommandRequest( BaseRequest ): + " changes" ) - def _HandleBooleanResponse( self ): - if self._response: - return vimsupport.EchoText( 'Yes' ) - vimsupport.EchoText( 'No' ) + def _HandleBasicResponse( self ): + vimsupport.EchoText( self._response ) def _HandleMessageResponse( self ):