aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/inlay_hints.rs
diff options
context:
space:
mode:
authorJacob Pratt <[email protected]>2021-01-10 09:14:39 +0000
committerJacob Pratt <[email protected]>2021-01-10 09:23:32 +0000
commit5e81892d4dd3b8353d11df8b9239432b5aa10512 (patch)
tree7a75e5b98a59e6d67b55f06bb2d1194a2b2c332a /crates/ide/src/inlay_hints.rs
parent22566ecd1b3f64c0b5d577ea3dac161ebb23eda4 (diff)
Skip leading underscores unconditionally
Diffstat (limited to 'crates/ide/src/inlay_hints.rs')
-rw-r--r--crates/ide/src/inlay_hints.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index 2ad8c33f2..3e9a65d9c 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -354,8 +354,11 @@ 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 let num_leading_underscores =
358 argument_string.bytes().take_while(|&c| c == b'_').count();
359
357 // Does the argument name begin with the parameter name? Ignore leading underscores. 360 // Does the argument name begin with the parameter name? Ignore leading underscores.
358 let mut arg_bytes = argument_string.bytes().skip_while(|&c| c == b'_'); 361 let mut arg_bytes = argument_string.bytes().skip(num_leading_underscores);
359 let starts_with_pattern = param_name.bytes().all( 362 let starts_with_pattern = param_name.bytes().all(
360 |expected| matches!(arg_bytes.next(), Some(actual) if expected.eq_ignore_ascii_case(&actual)), 363 |expected| matches!(arg_bytes.next(), Some(actual) if expected.eq_ignore_ascii_case(&actual)),
361 ); 364 );
@@ -365,7 +368,7 @@ fn is_argument_similar_to_param_name(
365 } 368 }
366 369
367 // Does the argument name end with the parameter name? 370 // Does the argument name end with the parameter name?
368 let mut arg_bytes = argument_string.bytes(); 371 let mut arg_bytes = argument_string.bytes().skip(num_leading_underscores);
369 param_name.bytes().rev().all( 372 param_name.bytes().rev().all(
370 |expected| matches!(arg_bytes.next_back(), Some(actual) if expected.eq_ignore_ascii_case(&actual)), 373 |expected| matches!(arg_bytes.next_back(), Some(actual) if expected.eq_ignore_ascii_case(&actual)),
371 ) 374 )