File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
crates/ide-assists/src/handlers Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ pub(crate) fn replace_is_method_with_if_let_method(
31
31
ast:: Expr :: MethodCallExpr ( call) => call,
32
32
_ => return None ,
33
33
} ;
34
+ if ctx. offset ( ) > if_expr. then_branch ( ) ?. stmt_list ( ) ?. l_curly_token ( ) ?. text_range ( ) . end ( ) {
35
+ return None ;
36
+ }
34
37
35
38
let name_ref = call_expr. name_ref ( ) ?;
36
39
match name_ref. text ( ) . as_str ( ) {
@@ -188,6 +191,21 @@ fn main() {
188
191
let x = Ok(1);
189
192
if x.is_e$0rr() {}
190
193
}
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
+ }
191
209
"# ,
192
210
) ;
193
211
}
You can’t perform that action at this time.
0 commit comments