about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYoung-Flash <871946895@qq.com>2023-10-14 11:05:38 +0800
committerYoung-Flash <871946895@qq.com>2023-10-14 11:05:38 +0800
commitbc34e8f1ad252aeda6064708abe3af944b6faf5d (patch)
tree5fe1f272bba73ecf69b915ee51b1d1f589bd9dd3
parent5bbca22720508798d4eda888d8c91f58d29e1f34 (diff)
downloadrust-bc34e8f1ad252aeda6064708abe3af944b6faf5d.tar.gz
rust-bc34e8f1ad252aeda6064708abe3af944b6faf5d.zip
feat: make cursor select at _tmp
-rw-r--r--crates/ide-assists/src/handlers/replace_is_method_with_if_let_method.rs8
-rw-r--r--crates/ide-assists/src/tests/generated.rs2
2 files changed, 5 insertions, 5 deletions
diff --git a/crates/ide-assists/src/handlers/replace_is_method_with_if_let_method.rs b/crates/ide-assists/src/handlers/replace_is_method_with_if_let_method.rs
index b897ddc2457..e5b4c33eb34 100644
--- a/crates/ide-assists/src/handlers/replace_is_method_with_if_let_method.rs
+++ b/crates/ide-assists/src/handlers/replace_is_method_with_if_let_method.rs
@@ -16,7 +16,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
 // ```
 // fn main() {
 //     let x = Some(1);
-//     if let Some(_tmp) = x {}
+//     if let Some(${0:_tmp}) = x {}
 // }
 // ```
 pub(crate) fn replace_is_method_with_if_let_method(
@@ -44,7 +44,7 @@ pub(crate) fn replace_is_method_with_if_let_method(
             };
 
             acc.add(AssistId(assist_id, AssistKind::RefactorRewrite), message, target, |edit| {
-                let replacement = format!("let {}(_tmp) = {}", text, receiver);
+                let replacement = format!("let {}({}) = {}", text, "${0:_tmp}", receiver);
                 edit.replace(target, replacement);
             })
         }
@@ -71,7 +71,7 @@ fn main() {
             r#"
 fn main() {
     let x = Some(1);
-    if let Some(_tmp) = x {}
+    if let Some(${0:_tmp}) = x {}
 }
 "#,
         );
@@ -103,7 +103,7 @@ fn main() {
             r#"
 fn main() {
     let x = Ok(1);
-    if let Ok(_tmp) = x {}
+    if let Ok(${0:_tmp}) = x {}
 }
 "#,
         );
diff --git a/crates/ide-assists/src/tests/generated.rs b/crates/ide-assists/src/tests/generated.rs
index d2b801336a5..6b4a9744087 100644
--- a/crates/ide-assists/src/tests/generated.rs
+++ b/crates/ide-assists/src/tests/generated.rs
@@ -2571,7 +2571,7 @@ fn main() {
         r#####"
 fn main() {
     let x = Some(1);
-    if let Some(_tmp) = x {}
+    if let Some(${0:_tmp}) = x {}
 }
 "#####,
     )