Skip to content

Commit

Permalink
Do not use a full line as description for symbol search
Browse files Browse the repository at this point in the history
This does lose a bit of context, but not much. Methods still have their
signatures visible and variables are... well... variables.

The idea is, if a client wants to later do filtering and sorting of
symbols, we should not be doing that on the whole line, which might be
left padded with tabs and have other punctuation. We already had a
report that this does not work well. It almost works if a client
`strip()`s the description before using it at all.

LSP completer instead uses `extra_data` to supply identifier name and
kind, but omnisharp-roslyn does not provide us with a symbol kind and
thus we can only put `ref[ 'Text' ]` in the description.
  • Loading branch information
bstaletic committed Jan 10, 2024
1 parent b34008a commit ed2afdb
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions ycmd/completers/cs/cs_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,31 +633,23 @@ def _GoToSymbol( self, request_data, args ):
if quickfixes:
if len( quickfixes ) == 1:
ref = quickfixes[ 0 ]
ref_file = ref[ 'FileName' ]
ref_line = ref[ 'Line' ]
lines = GetFileLines( request_data, ref_file )
line = lines[ min( len( lines ), ref_line - 1 ) ]
return responses.BuildGoToResponseFromLocation(
_BuildLocation(
request_data,
ref_file,
ref_line,
ref[ 'FileName' ],
ref[ 'Line' ],
ref[ 'Column' ] ),
line )
ref[ 'Text' ] )
else:
goto_locations = []
for ref in quickfixes:
ref_file = ref[ 'FileName' ]
ref_line = ref[ 'Line' ]
lines = GetFileLines( request_data, ref_file )
line = lines[ min( len( lines ), ref_line - 1 ) ]
goto_locations.append(
responses.BuildGoToResponseFromLocation(
_BuildLocation( request_data,
ref_file,
ref_line,
ref[ 'FileName' ],
ref[ 'Line' ],
ref[ 'Column' ] ),
line ) )
ref[ 'Text' ] ) )

return goto_locations
else:
Expand All @@ -670,17 +662,13 @@ def _GoToDocumentOutline( self, request_data ):
if response is not None and len( response ) > 0:
goto_locations = []
for ref in response:
ref_file = ref[ 'FileName' ]
ref_line = ref[ 'Line' ]
lines = GetFileLines( request_data, ref_file )
line = lines[ min( len( lines ), ref_line - 1 ) ]
goto_locations.append(
responses.BuildGoToResponseFromLocation(
_BuildLocation( request_data,
ref_file,
ref_line,
ref[ 'FileName' ],
ref[ 'Line' ],
ref[ 'Column' ] ),
line ) )
ref[ 'Text' ] ) )
if len( goto_locations ) > 1:
return goto_locations
return goto_locations[ 0 ]
Expand Down

0 comments on commit ed2afdb

Please sign in to comment.