diff --git a/python/ycm/diagnostic_interface.py b/python/ycm/diagnostic_interface.py index a7d765fd..e77f7146 100644 --- a/python/ycm/diagnostic_interface.py +++ b/python/ycm/diagnostic_interface.py @@ -63,9 +63,20 @@ def _UpdateSquiggles( buffer_number_to_line_to_diags ): for diags in line_to_diags.itervalues(): for diag in diags: location = diag[ 'location' ] - vimsupport.AddDiagnosticSyntaxMatch( location[ 'line_num' ] + 1, - location[ 'column_num' ] + 1, - _DiagnosticIsError( diag ) ) + is_error = _DiagnosticIsError( diag ) + + vimsupport.AddDiagnosticSyntaxMatch( + location[ 'line_num' ] + 1, + location[ 'column_num' ] + 1, + is_error = is_error ) + + for diag_range in diag[ 'ranges' ]: + vimsupport.AddDiagnosticSyntaxMatch( + diag_range[ 'start' ][ 'line_num' ] + 1, + diag_range[ 'start' ][ 'column_num' ] + 1, + diag_range[ 'end' ][ 'line_num' ] + 1, + diag_range[ 'end' ][ 'column_num' ] + 1, + is_error = is_error ) def _UpdateSigns( buffer_number_to_line_to_diags, next_sign_id ): diff --git a/python/ycm/vimsupport.py b/python/ycm/vimsupport.py index 4067010b..f269dd53 100644 --- a/python/ycm/vimsupport.py +++ b/python/ycm/vimsupport.py @@ -128,10 +128,23 @@ def ClearYcmSyntaxMatches(): # Returns the ID of the newly added match -def AddDiagnosticSyntaxMatch( line_num, column_num, is_error ): +def AddDiagnosticSyntaxMatch( line_num, + column_num, + line_end_num = None, + column_end_num = None, + is_error = True ): group = 'YcmErrorSection' if is_error else 'YcmWarningSection' - return GetIntValue( - "matchadd('{0}', '\%{1}l\%{2}c')".format( group, line_num, column_num ) ) + + if not line_end_num: + line_end_num = line_num + + if not column_end_num: + return GetIntValue( + "matchadd('{0}', '\%{1}l\%{2}c')".format( group, line_num, column_num ) ) + else: + return GetIntValue( + "matchadd('{0}', '\%{1}l\%{2}c.*\%{3}l\%{4}c')".format( + group, line_num, column_num, line_end_num, column_end_num ) ) # Given a dict like {'a': 1}, loads it into Vim as if you ran 'let g:a = 1'