aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_ide_api_light/src/assists/introduce_variable.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/crates/ra_ide_api_light/src/assists/introduce_variable.rs b/crates/ra_ide_api_light/src/assists/introduce_variable.rs
index e51cb22f0..230d23039 100644
--- a/crates/ra_ide_api_light/src/assists/introduce_variable.rs
+++ b/crates/ra_ide_api_light/src/assists/introduce_variable.rs
@@ -20,16 +20,15 @@ pub fn introduce_variable<'a>(ctx: AssistCtx) -> Option<Assist> {
20 20
21 buf.push_str("let var_name = "); 21 buf.push_str("let var_name = ");
22 expr.syntax().text().push_to(&mut buf); 22 expr.syntax().text().push_to(&mut buf);
23 let is_full_stmt = if let Some(expr_stmt) = ast::ExprStmt::cast(anchor_stmt) { 23 let full_stmt = ast::ExprStmt::cast(anchor_stmt);
24 let is_full_stmt = if let Some(expr_stmt) = full_stmt {
24 Some(expr.syntax()) == expr_stmt.expr().map(|e| e.syntax()) 25 Some(expr.syntax()) == expr_stmt.expr().map(|e| e.syntax())
25 } else { 26 } else {
26 false 27 false
27 }; 28 };
28 if is_full_stmt { 29 if is_full_stmt {
29 if let Some(last_child) = expr.syntax().last_child() { 30 if !full_stmt.unwrap().has_semi() {
30 if last_child.kind() != SEMI && !is_semi_right_after(expr.syntax()) { 31 buf.push_str(";");
31 buf.push_str(";");
32 }
33 } 32 }
34 edit.replace(expr.syntax().range(), buf); 33 edit.replace(expr.syntax().range(), buf);
35 } else { 34 } else {