Fix Vim E885: not possible to change sign
Clang will sometimes give a diagnostic for line 0, and Vim borks on placing signs for line 0.
This commit is contained in:
parent
fe24f02005
commit
def392d24c
@ -45,7 +45,9 @@ class DiagnosticInterface( object ):
|
|||||||
|
|
||||||
|
|
||||||
def UpdateWithNewDiagnostics( self, diags ):
|
def UpdateWithNewDiagnostics( self, diags ):
|
||||||
self._buffer_number_to_line_to_diags = _ConvertDiagListToDict( diags )
|
normalized_diags = [ _NormalizeDiagnostic( x ) for x in diags ]
|
||||||
|
self._buffer_number_to_line_to_diags = _ConvertDiagListToDict(
|
||||||
|
normalized_diags )
|
||||||
|
|
||||||
if self._user_options[ 'enable_diagnostic_signs' ]:
|
if self._user_options[ 'enable_diagnostic_signs' ]:
|
||||||
self._placed_signs, self._next_sign_id = _UpdateSigns(
|
self._placed_signs, self._next_sign_id = _UpdateSigns(
|
||||||
@ -58,7 +60,7 @@ class DiagnosticInterface( object ):
|
|||||||
|
|
||||||
if self._user_options[ 'always_populate_location_list' ]:
|
if self._user_options[ 'always_populate_location_list' ]:
|
||||||
vimsupport.SetLocationList(
|
vimsupport.SetLocationList(
|
||||||
vimsupport.ConvertDiagnosticsToQfList( diags ) )
|
vimsupport.ConvertDiagnosticsToQfList( normalized_diags ) )
|
||||||
|
|
||||||
|
|
||||||
def _EchoDiagnosticForLine( self, line_num ):
|
def _EchoDiagnosticForLine( self, line_num ):
|
||||||
@ -204,6 +206,16 @@ def _DiagnosticIsError( diag ):
|
|||||||
return diag[ 'kind' ] == 'ERROR'
|
return diag[ 'kind' ] == 'ERROR'
|
||||||
|
|
||||||
|
|
||||||
|
def _NormalizeDiagnostic( diag ):
|
||||||
|
def ClampToOne( value ):
|
||||||
|
return value if value > 0 else 1
|
||||||
|
|
||||||
|
location = diag[ 'location' ]
|
||||||
|
location[ 'column_num' ] = ClampToOne( location[ 'column_num' ] )
|
||||||
|
location[ 'line_num' ] = ClampToOne( location[ 'line_num' ] )
|
||||||
|
return diag
|
||||||
|
|
||||||
|
|
||||||
class _DiagSignPlacement( namedtuple( "_DiagSignPlacement",
|
class _DiagSignPlacement( namedtuple( "_DiagSignPlacement",
|
||||||
[ 'id', 'line', 'buffer', 'is_error' ] ) ):
|
[ 'id', 'line', 'buffer', 'is_error' ] ) ):
|
||||||
# We want two signs that have different ids but the same location to compare
|
# We want two signs that have different ids but the same location to compare
|
||||||
|
Loading…
Reference in New Issue
Block a user