@@ -275,7 +275,6 @@ fn completion_item(
275
275
completion_trigger_character : Option < char > ,
276
276
item : CompletionItem ,
277
277
) {
278
- let original_completion_item = item. clone ( ) ;
279
278
let insert_replace_support = config. insert_replace_support ( ) . then_some ( tdpp. position ) ;
280
279
let ref_match = item. ref_match ( ) ;
281
280
@@ -297,7 +296,7 @@ fn completion_item(
297
296
// non-trivial mapping here.
298
297
let mut text_edit = None ;
299
298
let source_range = item. source_range ;
300
- for indel in item. text_edit {
299
+ for indel in & item. text_edit {
301
300
if indel. delete . contains_range ( source_range) {
302
301
// Extract this indel as the main edit
303
302
text_edit = Some ( if indel. delete == source_range {
@@ -349,7 +348,7 @@ fn completion_item(
349
348
something_to_resolve |= item. documentation . is_some ( ) ;
350
349
None
351
350
} else {
352
- item. documentation . map ( documentation)
351
+ item. documentation . clone ( ) . map ( documentation)
353
352
} ;
354
353
355
354
let mut lsp_item = lsp_types:: CompletionItem {
@@ -373,10 +372,10 @@ fn completion_item(
373
372
} else {
374
373
lsp_item. label_details = Some ( lsp_types:: CompletionItemLabelDetails {
375
374
detail : item. label_detail . as_ref ( ) . map ( ToString :: to_string) ,
376
- description : item. detail ,
375
+ description : item. detail . clone ( ) ,
377
376
} ) ;
378
377
}
379
- } else if let Some ( label_detail) = item. label_detail {
378
+ } else if let Some ( label_detail) = & item. label_detail {
380
379
lsp_item. label . push_str ( label_detail. as_str ( ) ) ;
381
380
}
382
381
@@ -385,6 +384,7 @@ fn completion_item(
385
384
let imports =
386
385
if config. completion ( None ) . enable_imports_on_the_fly && !item. import_to_add . is_empty ( ) {
387
386
item. import_to_add
387
+ . clone ( )
388
388
. into_iter ( )
389
389
. map ( |( import_path, import_name) | lsp_ext:: CompletionImport {
390
390
full_import_path : import_path,
@@ -402,7 +402,7 @@ fn completion_item(
402
402
version,
403
403
trigger_character : completion_trigger_character,
404
404
for_ref : true ,
405
- hash : completion_item_hash ( & original_completion_item , true ) ,
405
+ hash : completion_item_hash ( & item , true ) ,
406
406
} ;
407
407
Some ( to_value ( ref_resolve_data) . unwrap ( ) )
408
408
} else {
@@ -414,7 +414,7 @@ fn completion_item(
414
414
version,
415
415
trigger_character : completion_trigger_character,
416
416
for_ref : false ,
417
- hash : completion_item_hash ( & original_completion_item , false ) ,
417
+ hash : completion_item_hash ( & item , false ) ,
418
418
} ;
419
419
( ref_resolve_data, Some ( to_value ( resolve_data) . unwrap ( ) ) )
420
420
} else {
0 commit comments