Fix YcmShowDetailedDiagnostic command on line without a diagnostic

The YcmShowDetailedDiagnostic command raises a NoneType exception on a line
with no diagnostic.
This commit is contained in:
micbou 2018-05-24 11:34:48 +02:00
parent e5b28f5c32
commit a7ec7a6cd9
No known key found for this signature in database
GPG Key ID: C7E8FD1F3BDA1E05
3 changed files with 19 additions and 3 deletions

View File

@ -1900,8 +1900,8 @@ The *GoToDeclaration* subcommand
Looks up the symbol under the cursor and jumps to its declaration. Looks up the symbol under the cursor and jumps to its declaration.
Supported in filetypes: 'c, cpp, objc, objcpp, cuda, cs, go, java, python, rust, Supported in filetypes: 'c, cpp, objc, objcpp, cuda, cs, go, java, python,
typescript' rust, typescript'
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
The *GoToDefinition* subcommand The *GoToDefinition* subcommand

View File

@ -386,6 +386,22 @@ def YouCompleteMe_ShowDetailedDiagnostic_MessageFromServer_test(
] ) ] )
@YouCompleteMeInstance()
@patch( 'ycm.vimsupport.PostVimMessage', new_callable = ExtendedMock )
def YouCompleteMe_ShowDetailedDiagnostic_Exception_test(
ycm, post_vim_message ):
current_buffer = VimBuffer( 'buffer' )
with MockVimBuffers( [ current_buffer ], current_buffer ):
with patch( 'ycm.client.base_request._JsonFromFuture',
side_effect = RuntimeError( 'Some exception' ) ):
ycm.ShowDetailedDiagnostic(),
post_vim_message.assert_has_exact_calls( [
call( 'Some exception', truncate = False )
] )
@YouCompleteMeInstance() @YouCompleteMeInstance()
@patch( 'ycm.vimsupport.PostVimMessage', new_callable = ExtendedMock ) @patch( 'ycm.vimsupport.PostVimMessage', new_callable = ExtendedMock )
def YouCompleteMe_ShowDiagnostics_FiletypeNotSupported_test( ycm, def YouCompleteMe_ShowDiagnostics_FiletypeNotSupported_test( ycm,

View File

@ -660,7 +660,7 @@ class YouCompleteMe( object ):
detailed_diagnostic = BaseRequest().PostDataToHandler( detailed_diagnostic = BaseRequest().PostDataToHandler(
BuildRequestData(), 'detailed_diagnostic' ) BuildRequestData(), 'detailed_diagnostic' )
if 'message' in detailed_diagnostic: if detailed_diagnostic and 'message' in detailed_diagnostic:
vimsupport.PostVimMessage( detailed_diagnostic[ 'message' ], vimsupport.PostVimMessage( detailed_diagnostic[ 'message' ],
warning = False ) warning = False )