aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/introduce_variable.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/introduce_variable.rs')
-rw-r--r--crates/ra_assists/src/introduce_variable.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/ra_assists/src/introduce_variable.rs b/crates/ra_assists/src/introduce_variable.rs
index ce28132c9..df6c58989 100644
--- a/crates/ra_assists/src/introduce_variable.rs
+++ b/crates/ra_assists/src/introduce_variable.rs
@@ -48,7 +48,7 @@ pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option
48 if !full_stmt.unwrap().has_semi() { 48 if !full_stmt.unwrap().has_semi() {
49 buf.push_str(";"); 49 buf.push_str(";");
50 } 50 }
51 edit.replace(expr.syntax().range(), buf); 51 edit.replace(expr.syntax().text_range(), buf);
52 } else { 52 } else {
53 buf.push_str(";"); 53 buf.push_str(";");
54 54
@@ -66,14 +66,14 @@ pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option
66 buf.push_str(text); 66 buf.push_str(text);
67 } 67 }
68 68
69 edit.target(expr.syntax().range()); 69 edit.target(expr.syntax().text_range());
70 edit.replace(expr.syntax().range(), "var_name".to_string()); 70 edit.replace(expr.syntax().text_range(), "var_name".to_string());
71 edit.insert(anchor_stmt.range().start(), buf); 71 edit.insert(anchor_stmt.text_range().start(), buf);
72 if wrap_in_block { 72 if wrap_in_block {
73 edit.insert(anchor_stmt.range().end(), " }"); 73 edit.insert(anchor_stmt.text_range().end(), " }");
74 } 74 }
75 } 75 }
76 edit.set_cursor(anchor_stmt.range().start() + cursor_offset); 76 edit.set_cursor(anchor_stmt.text_range().start() + cursor_offset);
77 }); 77 });
78 78
79 ctx.build() 79 ctx.build()