diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide_api/src/call_info.rs | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs index 831c4ad12..29fa7d30b 100644 --- a/crates/ra_ide_api/src/call_info.rs +++ b/crates/ra_ide_api/src/call_info.rs | |||
@@ -40,13 +40,8 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal | |||
40 | } else if num_params > 1 { | 40 | } else if num_params > 1 { |
41 | // Count how many parameters into the call we are. | 41 | // Count how many parameters into the call we are. |
42 | if let Some(arg_list) = calling_node.arg_list() { | 42 | if let Some(arg_list) = calling_node.arg_list() { |
43 | // Number of arguments specified at the caller site | 43 | // Number of arguments specified at the call site |
44 | let mut num_args_of_call = arg_list.args().count(); | 44 | let num_args_at_callsite = arg_list.args().count(); |
45 | |||
46 | // If we are calling a method account for the `self` argument. | ||
47 | if has_self { | ||
48 | num_args_of_call = num_args_of_call + 1; | ||
49 | } | ||
50 | 45 | ||
51 | let arg_list_range = arg_list.syntax().range(); | 46 | let arg_list_range = arg_list.syntax().range(); |
52 | if !arg_list_range.contains_inclusive(position.offset) { | 47 | if !arg_list_range.contains_inclusive(position.offset) { |
@@ -54,12 +49,18 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal | |||
54 | return None; | 49 | return None; |
55 | } | 50 | } |
56 | 51 | ||
57 | let param = arg_list | 52 | let mut param = std::cmp::min( |
58 | .args() | 53 | num_args_at_callsite, |
59 | .position(|arg| arg.syntax().range().contains(position.offset)) | 54 | arg_list |
60 | .or(Some(num_params - 1)) | 55 | .args() |
61 | .min(Some(num_args_of_call)) | 56 | .take_while(|arg| arg.syntax().range().end() < position.offset) |
62 | .unwrap(); | 57 | .count(), |
58 | ); | ||
59 | |||
60 | // If we are in a method account for `self` | ||
61 | if has_self { | ||
62 | param = param + 1; | ||
63 | } | ||
63 | 64 | ||
64 | call_info.active_parameter = Some(param); | 65 | call_info.active_parameter = Some(param); |
65 | } | 66 | } |