aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/inlay_hints.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index ddab9a168..2ad8c33f2 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -354,17 +354,21 @@ fn is_argument_similar_to_param_name(
354 match get_string_representation(argument) { 354 match get_string_representation(argument) {
355 None => false, 355 None => false,
356 Some(argument_string) => { 356 Some(argument_string) => {
357 // Does the argument name begin with the parameter name? Ignore leading underscores.
357 let mut arg_bytes = argument_string.bytes().skip_while(|&c| c == b'_'); 358 let mut arg_bytes = argument_string.bytes().skip_while(|&c| c == b'_');
358 let starts_with_pattern = param_name.bytes().all( 359 let starts_with_pattern = param_name.bytes().all(
359 |expected| matches!(arg_bytes.next(), Some(actual) if expected.eq_ignore_ascii_case(&actual)), 360 |expected| matches!(arg_bytes.next(), Some(actual) if expected.eq_ignore_ascii_case(&actual)),
360 ); 361 );
361 362
363 if starts_with_pattern {
364 return true;
365 }
366
367 // Does the argument name end with the parameter name?
362 let mut arg_bytes = argument_string.bytes(); 368 let mut arg_bytes = argument_string.bytes();
363 let ends_with_pattern = param_name.bytes().rev().all( 369 param_name.bytes().rev().all(
364 |expected| matches!(arg_bytes.next_back(), Some(actual) if expected.eq_ignore_ascii_case(&actual)), 370 |expected| matches!(arg_bytes.next_back(), Some(actual) if expected.eq_ignore_ascii_case(&actual)),
365 ); 371 )
366
367 starts_with_pattern || ends_with_pattern
368 } 372 }
369 } 373 }
370} 374}