Skip to content

Commit a28aa17

Browse files
committed
Add turbo-fish works after ()
1 parent 2777f8c commit a28aa17

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

crates/ra_assists/src/handlers/add_turbo_fish.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ use crate::{
2525
// }
2626
// ```
2727
pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
28-
let ident = ctx.find_token_at_offset(SyntaxKind::IDENT)?;
28+
let ident = ctx.find_token_at_offset(SyntaxKind::IDENT).or_else(|| {
29+
let arg_list = ctx.find_node_at_offset::<ast::ArgList>()?;
30+
if arg_list.args().count() > 0 {
31+
return None;
32+
}
33+
mark::hit!(add_turbo_fish_after_call);
34+
arg_list.l_paren_token()?.prev_token().filter(|it| it.kind() == SyntaxKind::IDENT)
35+
})?;
2936
let next_token = ident.next_token()?;
3037
if next_token.kind() == T![::] {
3138
mark::hit!(add_turbo_fish_one_fish_is_enough);
@@ -82,6 +89,26 @@ fn main() {
8289
);
8390
}
8491

92+
#[test]
93+
fn add_turbo_fish_after_call() {
94+
mark::check!(add_turbo_fish_after_call);
95+
check_assist(
96+
add_turbo_fish,
97+
r#"
98+
fn make<T>() -> T {}
99+
fn main() {
100+
make()<|>;
101+
}
102+
"#,
103+
r#"
104+
fn make<T>() -> T {}
105+
fn main() {
106+
make::<${0:_}>();
107+
}
108+
"#,
109+
);
110+
}
111+
85112
#[test]
86113
fn add_turbo_fish_method() {
87114
check_assist(

0 commit comments

Comments
 (0)