From f756d5da063461c99c20266dc4896d8388fe28b9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 5 Feb 2020 13:41:43 +0100 Subject: Better cursor placement when merging arms --- crates/ra_assists/src/assists/merge_match_arms.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'crates/ra_assists/src') diff --git a/crates/ra_assists/src/assists/merge_match_arms.rs b/crates/ra_assists/src/assists/merge_match_arms.rs index 8af30866c..64c9379da 100644 --- a/crates/ra_assists/src/assists/merge_match_arms.rs +++ b/crates/ra_assists/src/assists/merge_match_arms.rs @@ -40,7 +40,17 @@ pub(crate) fn merge_match_arms(ctx: AssistCtx) -> Option) -> Option start + TextUnit::from_usize(arm.len()) - back_offset, + CursorPos::InPat(offset) => offset, + }); edit.replace(TextRange::from_to(start, end), arm); }) } @@ -204,7 +217,7 @@ mod tests { fn main() { match X::A { - X::A =><|> 92, + X::A<|> => 92, X::B => 92, X::C => 92, X::D => 62, @@ -217,7 +230,7 @@ mod tests { fn main() { match X::A { - X::A | X::B | X::C =><|> 92, + X::A<|> | X::B | X::C => 92, X::D => 62, _ => panic!(), } -- cgit v1.2.3