aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/handlers/introduce_variable.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-05-06 11:51:28 +0100
committerAleksey Kladov <[email protected]>2020-05-06 11:51:28 +0100
commit233f01c9ba555e5d06f336cb0ff64e7a83e4a23a (patch)
tree7922dca3f7c4133e2616257be537428337e479d6 /crates/ra_assists/src/handlers/introduce_variable.rs
parentede8906844e206f252810d58533538cf1fb326d4 (diff)
Move target to AssistLabel
Target is used for assists sorting, so we need it before we compute the action.
Diffstat (limited to 'crates/ra_assists/src/handlers/introduce_variable.rs')
-rw-r--r--crates/ra_assists/src/handlers/introduce_variable.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/ra_assists/src/handlers/introduce_variable.rs b/crates/ra_assists/src/handlers/introduce_variable.rs
index 9c2c20b22..3c340ff3b 100644
--- a/crates/ra_assists/src/handlers/introduce_variable.rs
+++ b/crates/ra_assists/src/handlers/introduce_variable.rs
@@ -42,7 +42,8 @@ pub(crate) fn introduce_variable(ctx: AssistCtx) -> Option<Assist> {
42 if indent.kind() != WHITESPACE { 42 if indent.kind() != WHITESPACE {
43 return None; 43 return None;
44 } 44 }
45 ctx.add_assist(AssistId("introduce_variable"), "Extract into variable", move |edit| { 45 let target = expr.syntax().text_range();
46 ctx.add_assist(AssistId("introduce_variable"), "Extract into variable", target, move |edit| {
46 let mut buf = String::new(); 47 let mut buf = String::new();
47 48
48 let cursor_offset = if wrap_in_block { 49 let cursor_offset = if wrap_in_block {
@@ -79,7 +80,6 @@ pub(crate) fn introduce_variable(ctx: AssistCtx) -> Option<Assist> {
79 buf.push_str(text); 80 buf.push_str(text);
80 } 81 }
81 82
82 edit.target(expr.syntax().text_range());
83 edit.replace(expr.syntax().text_range(), "var_name".to_string()); 83 edit.replace(expr.syntax().text_range(), "var_name".to_string());
84 edit.insert(anchor_stmt.text_range().start(), buf); 84 edit.insert(anchor_stmt.text_range().start(), buf);
85 if wrap_in_block { 85 if wrap_in_block {