@@ -219,16 +219,58 @@ pub(crate) fn completion_item(
219
219
res
220
220
}
221
221
222
- pub ( crate ) fn signature_help ( call_info : CallInfo , concise : bool ) -> lsp_types:: SignatureHelp {
223
- let parameters = call_info
224
- . parameter_labels ( )
225
- . map ( |label| lsp_types:: ParameterInformation {
226
- label : lsp_types:: ParameterLabel :: Simple ( label. to_string ( ) ) ,
227
- documentation : None ,
228
- } )
229
- . collect ( ) ;
222
+ pub ( crate ) fn signature_help (
223
+ call_info : CallInfo ,
224
+ concise : bool ,
225
+ label_offsets : bool ,
226
+ ) -> lsp_types:: SignatureHelp {
227
+ let ( label, parameters) = match ( concise, label_offsets) {
228
+ ( _, false ) => {
229
+ let params = call_info
230
+ . parameter_labels ( )
231
+ . map ( |label| lsp_types:: ParameterInformation {
232
+ label : lsp_types:: ParameterLabel :: Simple ( label. to_string ( ) ) ,
233
+ documentation : None ,
234
+ } )
235
+ . collect :: < Vec < _ > > ( ) ;
236
+ let label =
237
+ if concise { call_info. parameter_labels ( ) . join ( ", " ) } else { call_info. signature } ;
238
+ ( label, params)
239
+ }
240
+ ( false , true ) => {
241
+ let params = call_info
242
+ . parameter_ranges ( )
243
+ . iter ( )
244
+ . map ( |it| [ u32:: from ( it. start ( ) ) . into ( ) , u32:: from ( it. end ( ) ) . into ( ) ] )
245
+ . map ( |label_offsets| lsp_types:: ParameterInformation {
246
+ label : lsp_types:: ParameterLabel :: LabelOffsets ( label_offsets) ,
247
+ documentation : None ,
248
+ } )
249
+ . collect :: < Vec < _ > > ( ) ;
250
+ ( call_info. signature , params)
251
+ }
252
+ ( true , true ) => {
253
+ let mut params = Vec :: new ( ) ;
254
+ let mut label = String :: new ( ) ;
255
+ let mut first = true ;
256
+ for param in call_info. parameter_labels ( ) {
257
+ if !first {
258
+ label. push_str ( ", " ) ;
259
+ }
260
+ first = false ;
261
+ let start = label. len ( ) as u64 ;
262
+ label. push_str ( param) ;
263
+ let end = label. len ( ) as u64 ;
264
+ params. push ( lsp_types:: ParameterInformation {
265
+ label : lsp_types:: ParameterLabel :: LabelOffsets ( [ start, end] ) ,
266
+ documentation : None ,
267
+ } ) ;
268
+ }
269
+
270
+ ( label, params)
271
+ }
272
+ } ;
230
273
231
- let label = if concise { call_info. parameter_labels ( ) . join ( ", " ) } else { call_info. signature } ;
232
274
let documentation = call_info. doc . map ( |doc| {
233
275
lsp_types:: Documentation :: MarkupContent ( lsp_types:: MarkupContent {
234
276
kind : lsp_types:: MarkupKind :: Markdown ,
0 commit comments