From 81aab500c677420e4911371e13876faaf211219c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Thu, 9 Apr 2020 13:47:48 +0300 Subject: Hide parameter hints for single-argument functions with the same name --- crates/ra_ide/src/inlay_hints.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index da9f55a69..45b9f7802 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -235,7 +235,10 @@ fn should_show_param_hint( param_name: &str, argument: &ast::Expr, ) -> bool { - if param_name.is_empty() || is_argument_similar_to_param(argument, param_name) { + if param_name.is_empty() + || is_argument_similar_to_param(argument, param_name) + || Some(param_name) == fn_signature.name.as_ref().map(String::as_str) + { return false; } @@ -247,10 +250,7 @@ fn should_show_param_hint( // avoid displaying hints for common functions like map, filter, etc. // or other obvious words used in std - if parameters_len == 1 && is_obvious_param(param_name) { - return false; - } - true + parameters_len != 1 || !is_obvious_param(param_name) } fn is_argument_similar_to_param(argument: &ast::Expr, param_name: &str) -> bool { @@ -1086,6 +1086,8 @@ impl Test { } fn no_hints_expected(&self, _: i32, test_var: i32) {} + + fn frob(&self, frob: bool) {} } struct Param {} @@ -1093,6 +1095,8 @@ struct Param {} fn different_order(param: &Param) {} fn different_order_mut(param: &mut Param) {} +fn twiddle(twiddle: bool) {} + fn main() { let container: TestVarContainer = TestVarContainer { test_var: 42 }; let test: Test = Test {}; @@ -1105,6 +1109,9 @@ fn main() { let test_var: i32 = 55; test_processed.no_hints_expected(22, test_var); test_processed.no_hints_expected(33, container.test_var); + test_processed.frob(false); + + twiddle(true); let param_begin: Param = Param {}; different_order(¶m_begin); -- cgit v1.2.3