about summary refs log tree commit diff
diff options
context:
space:
mode:
authorroife <roifewu@gmail.com>2024-01-10 15:00:58 +0800
committerroife <roifewu@gmail.com>2024-01-10 15:00:58 +0800
commitd327f3036c2db0cffb91807c301d48f8e37165e2 (patch)
treeeed7bccc7861deaa6826e29436e2dff86b4cec5c
parentbc54775c9d7026b1ca616ca43fd34ff6f53d668a (diff)
downloadrust-d327f3036c2db0cffb91807c301d48f8e37165e2.tar.gz
rust-d327f3036c2db0cffb91807c301d48f8e37165e2.zip
Add test 'comments_in_block_expr' in in 'extract_function'
-rw-r--r--crates/ide-assists/src/handlers/extract_function.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/crates/ide-assists/src/handlers/extract_function.rs b/crates/ide-assists/src/handlers/extract_function.rs
index 3d91cb6a0f8..1eb28626f75 100644
--- a/crates/ide-assists/src/handlers/extract_function.rs
+++ b/crates/ide-assists/src/handlers/extract_function.rs
@@ -5977,6 +5977,37 @@ fn $0fun_name() -> ControlFlow<()> {
     }
 
     #[test]
+    fn comments_in_block_expr() {
+        check_assist(
+            extract_function,
+            r#"
+fn f() {
+    let c = $0{
+        // comment 1
+        let a = 2 + 3;
+        // comment 2
+        let b = 5;
+        a + b
+    }$0;
+}
+"#,
+            r#"
+fn f() {
+    let c = fun_name();
+}
+
+fn $0fun_name() -> i32 {
+    // comment 1
+    let a = 2 + 3;
+    // comment 2
+    let b = 5;
+    a + b
+}
+"#,
+        );
+    }
+
+    #[test]
     fn in_left_curly_is_not_applicable() {
         cov_mark::check!(extract_function_in_braces_is_not_applicable);
         check_assist_not_applicable(extract_function, r"fn foo() { $0}$0");