diff options
author | Vladyslav Katasonov <[email protected]> | 2021-02-16 02:55:47 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-03-02 13:23:00 +0000 |
commit | f915ab79fa1b11982b8e82e2db5b2486a893bed4 (patch) | |
tree | a6242f0fa47e1c9893faca77174a451a8601e852 /crates/ide_assists | |
parent | 3b75dda7454ca26afc70aae55d48706441eceff9 (diff) |
suggest parameter name before function name
Diffstat (limited to 'crates/ide_assists')
-rw-r--r-- | crates/ide_assists/src/handlers/extract_variable.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ide_assists/src/handlers/extract_variable.rs b/crates/ide_assists/src/handlers/extract_variable.rs index 32e54fd57..2c47be987 100644 --- a/crates/ide_assists/src/handlers/extract_variable.rs +++ b/crates/ide_assists/src/handlers/extract_variable.rs | |||
@@ -176,9 +176,9 @@ impl Anchor { | |||
176 | 176 | ||
177 | fn suggest_variable_name(ctx: &AssistContext, expr: &ast::Expr) -> String { | 177 | fn suggest_variable_name(ctx: &AssistContext, expr: &ast::Expr) -> String { |
178 | // FIXME: account for existing names in the scope | 178 | // FIXME: account for existing names in the scope |
179 | suggest_name_from_func(expr) | 179 | suggest_name_from_param(ctx, expr) |
180 | .or_else(|| suggest_name_from_func(expr)) | ||
180 | .or_else(|| suggest_name_from_method(expr)) | 181 | .or_else(|| suggest_name_from_method(expr)) |
181 | .or_else(|| suggest_name_from_param(ctx, expr)) | ||
182 | .or_else(|| suggest_name_by_type(ctx, expr)) | 182 | .or_else(|| suggest_name_by_type(ctx, expr)) |
183 | .unwrap_or_else(|| "var_name".to_string()) | 183 | .unwrap_or_else(|| "var_name".to_string()) |
184 | } | 184 | } |
@@ -815,7 +815,7 @@ fn foo() { | |||
815 | } | 815 | } |
816 | 816 | ||
817 | #[test] | 817 | #[test] |
818 | fn extract_var_function_name_has_precedence() { | 818 | fn extract_var_parameter_name_has_precedence_over_function() { |
819 | check_assist( | 819 | check_assist( |
820 | extract_variable, | 820 | extract_variable, |
821 | r#" | 821 | r#" |
@@ -829,8 +829,8 @@ fn foo() { | |||
829 | fn bar(test: u32, size: u32) | 829 | fn bar(test: u32, size: u32) |
830 | 830 | ||
831 | fn foo() { | 831 | fn foo() { |
832 | let $0symbol_size = symbol_size(1, 2); | 832 | let $0size = symbol_size(1, 2); |
833 | bar(1, symbol_size); | 833 | bar(1, size); |
834 | } | 834 | } |
835 | "#, | 835 | "#, |
836 | ) | 836 | ) |