diff options
author | vsrs <[email protected]> | 2020-05-08 17:34:34 +0100 |
---|---|---|
committer | vsrs <[email protected]> | 2020-05-08 17:34:34 +0100 |
commit | 0ef17ef1ee9fb0ce7149176d12f4d225f6d01401 (patch) | |
tree | fa2f168120f36f8dbef5dc1e85fea0c0071639c2 /crates/ra_assists/src/handlers/merge_match_arms.rs | |
parent | 1be6320ea6cf7830195f80681fa0f43cc340da7e (diff) | |
parent | d3eb9d8eafbebca7da95fa8a4813b92eb5080500 (diff) |
Merge remote-tracking branch 'upstream/master' into uniformed_debug_lens
# Conflicts:
# editors/code/src/commands/runnables.ts
Diffstat (limited to 'crates/ra_assists/src/handlers/merge_match_arms.rs')
-rw-r--r-- | crates/ra_assists/src/handlers/merge_match_arms.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_assists/src/handlers/merge_match_arms.rs b/crates/ra_assists/src/handlers/merge_match_arms.rs index 7c4d9d55d..d4e38aa6a 100644 --- a/crates/ra_assists/src/handlers/merge_match_arms.rs +++ b/crates/ra_assists/src/handlers/merge_match_arms.rs | |||
@@ -6,7 +6,7 @@ use ra_syntax::{ | |||
6 | Direction, TextSize, | 6 | Direction, TextSize, |
7 | }; | 7 | }; |
8 | 8 | ||
9 | use crate::{Assist, AssistCtx, AssistId, TextRange}; | 9 | use crate::{AssistContext, AssistId, Assists, TextRange}; |
10 | 10 | ||
11 | // Assist: merge_match_arms | 11 | // Assist: merge_match_arms |
12 | // | 12 | // |
@@ -32,7 +32,7 @@ use crate::{Assist, AssistCtx, AssistId, TextRange}; | |||
32 | // } | 32 | // } |
33 | // } | 33 | // } |
34 | // ``` | 34 | // ``` |
35 | pub(crate) fn merge_match_arms(ctx: AssistCtx) -> Option<Assist> { | 35 | pub(crate) fn merge_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
36 | let current_arm = ctx.find_node_at_offset::<ast::MatchArm>()?; | 36 | let current_arm = ctx.find_node_at_offset::<ast::MatchArm>()?; |
37 | // Don't try to handle arms with guards for now - can add support for this later | 37 | // Don't try to handle arms with guards for now - can add support for this later |
38 | if current_arm.guard().is_some() { | 38 | if current_arm.guard().is_some() { |
@@ -45,7 +45,7 @@ pub(crate) fn merge_match_arms(ctx: AssistCtx) -> Option<Assist> { | |||
45 | InExpr(TextSize), | 45 | InExpr(TextSize), |
46 | InPat(TextSize), | 46 | InPat(TextSize), |
47 | } | 47 | } |
48 | let cursor_pos = ctx.frange.range.start(); | 48 | let cursor_pos = ctx.offset(); |
49 | let cursor_pos = if current_expr.syntax().text_range().contains(cursor_pos) { | 49 | let cursor_pos = if current_expr.syntax().text_range().contains(cursor_pos) { |
50 | CursorPos::InExpr(current_text_range.end() - cursor_pos) | 50 | CursorPos::InExpr(current_text_range.end() - cursor_pos) |
51 | } else { | 51 | } else { |
@@ -70,7 +70,7 @@ pub(crate) fn merge_match_arms(ctx: AssistCtx) -> Option<Assist> { | |||
70 | return None; | 70 | return None; |
71 | } | 71 | } |
72 | 72 | ||
73 | ctx.add_assist(AssistId("merge_match_arms"), "Merge match arms", current_text_range, |edit| { | 73 | acc.add(AssistId("merge_match_arms"), "Merge match arms", current_text_range, |edit| { |
74 | let pats = if arms_to_merge.iter().any(contains_placeholder) { | 74 | let pats = if arms_to_merge.iter().any(contains_placeholder) { |
75 | "_".into() | 75 | "_".into() |
76 | } else { | 76 | } else { |