Skip to content

Commit

Permalink
Store multiline diags for each line they appear on
Browse files Browse the repository at this point in the history
Diagnostic interface used to store multiline diags only on thte starting
line.
With this pull commit, _line_to_diags stores a multiline diagnostic for
each line in the range `diag['range']['start'/'end'].
  • Loading branch information
bstaletic committed Nov 6, 2023
1 parent 5bcccad commit 7a87944
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
10 changes: 6 additions & 4 deletions python/ycm/diagnostic_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,13 @@ def _UpdateSigns( self ):
def _ConvertDiagListToDict( self ):
self._line_to_diags = defaultdict( list )
for diag in self._diagnostics:
location = diag[ 'location' ]
bufnr = vimsupport.GetBufferNumberForFilename( location[ 'filepath' ] )
location_extent = diag[ 'location_extent' ]
start = location_extent[ 'start' ]
end = location_extent[ 'end' ]
bufnr = vimsupport.GetBufferNumberForFilename( start[ 'filepath' ] )
if bufnr == self._bufnr:
line_number = location[ 'line_num' ]
self._line_to_diags[ line_number ].append( diag )
for line_number in range( start[ 'line_num' ], end[ 'line_num' ] + 1 ):
self._line_to_diags[ line_number ].append( diag )

for diags in self._line_to_diags.values():
# We also want errors to be listed before warnings so that errors aren't
Expand Down
29 changes: 26 additions & 3 deletions python/ycm/tests/youcompleteme_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,14 @@ def YouCompleteMe_UpdateDiagnosticInterface( ycm, post_vim_message, *args ):
'line_num': 2,
'column_num': 31
},
# Looks strange but this is really what ycmd is returning.
'location_extent': {
'start': {
'filepath': '',
'filepath': 'buffer',
'line_num': 2,
'column_num': 31,
},
'end': {
'filepath': '',
'filepath': 'buffer',
'line_num': 2,
'column_num': 32,
}
Expand Down Expand Up @@ -624,6 +623,18 @@ def test_YouCompleteMe_ShowDiagnostics_DiagnosticsFound_DoNotOpenLocationList(
'filepath': 'buffer',
'line_num': 19,
'column_num': 2
},
'location_extent': {
'start': {
'filepath': 'buffer',
'line_num': 19,
'column_num': 2
},
'end': {
'filepath': 'buffer',
'line_num': 19,
'column_num': 3
}
}
}

Expand Down Expand Up @@ -673,6 +684,18 @@ def test_YouCompleteMe_ShowDiagnostics_DiagnosticsFound_OpenLocationList(
'filepath': 'buffer',
'line_num': 19,
'column_num': 2
},
'location_extent': {
'start': {
'filepath': 'buffer',
'line_num': 19,
'column_num': 2
},
'end': {
'filepath': 'buffer',
'line_num': 19,
'column_num': 2
}
}
}

Expand Down

0 comments on commit 7a87944

Please sign in to comment.