diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-06 11:52:57 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-06 11:52:57 +0100 |
commit | 4de3c3eedc1f6576d59e00f0ddde3c70c97be066 (patch) | |
tree | 7922dca3f7c4133e2616257be537428337e479d6 /crates/ra_assists/src/handlers/introduce_variable.rs | |
parent | ede8906844e206f252810d58533538cf1fb326d4 (diff) | |
parent | 233f01c9ba555e5d06f336cb0ff64e7a83e4a23a (diff) |
Merge #4341
4341: Move target to AssistLabel r=matklad a=matklad
Target is used for assists sorting, so we need it before we compute
the action.
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/handlers/introduce_variable.rs')
-rw-r--r-- | crates/ra_assists/src/handlers/introduce_variable.rs | 4 |
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 { |