Skip to content

Commit 259a01d

Browse files
authored
Merge pull request #20688 from A4-Tacks/fix-applicable-after-l-curly-replace-is-method-with-if-let
Fix applicable after l_curly for replace_is_method_with_if_let_method
2 parents 84bb405 + d374851 commit 259a01d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

crates/ide-assists/src/handlers/replace_is_method_with_if_let_method.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ pub(crate) fn replace_is_method_with_if_let_method(
3131
ast::Expr::MethodCallExpr(call) => call,
3232
_ => return None,
3333
};
34+
if ctx.offset() > if_expr.then_branch()?.stmt_list()?.l_curly_token()?.text_range().end() {
35+
return None;
36+
}
3437

3538
let name_ref = call_expr.name_ref()?;
3639
match name_ref.text().as_str() {
@@ -188,6 +191,21 @@ fn main() {
188191
let x = Ok(1);
189192
if x.is_e$0rr() {}
190193
}
194+
"#,
195+
);
196+
}
197+
198+
#[test]
199+
fn replace_is_some_with_if_let_some_not_applicable_after_l_curly() {
200+
check_assist_not_applicable(
201+
replace_is_method_with_if_let_method,
202+
r#"
203+
fn main() {
204+
let x = Some(1);
205+
if x.is_some() {
206+
()$0
207+
}
208+
}
191209
"#,
192210
);
193211
}

0 commit comments

Comments
 (0)