From d9828a57fcbff6c1bcaa9d2b6a54a08d8428a95f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 9 May 2020 16:21:10 +0200 Subject: Add From should not move the cursor --- .../src/handlers/add_from_impl_for_enum.rs | 25 ++++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs b/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs index 275184e24..6a49b7dbd 100644 --- a/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs +++ b/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs @@ -1,8 +1,5 @@ use ra_ide_db::RootDatabase; -use ra_syntax::{ - ast::{self, AstNode, NameOwner}, - TextSize, -}; +use ra_syntax::ast::{self, AstNode, NameOwner}; use stdx::format_to; use test_utils::tested_by; @@ -69,7 +66,6 @@ impl From<{0}> for {1} {{ variant_name ); edit.insert(start_offset, buf); - edit.set_cursor(start_offset + TextSize::of("\n\n")); }, ) } @@ -97,19 +93,20 @@ fn existing_from_impl( #[cfg(test)] mod tests { - use super::*; + use test_utils::covers; use crate::tests::{check_assist, check_assist_not_applicable}; - use test_utils::covers; + + use super::*; #[test] fn test_add_from_impl_for_enum() { check_assist( add_from_impl_for_enum, "enum A { <|>One(u32) }", - r#"enum A { One(u32) } + r#"enum A { <|>One(u32) } -<|>impl From for A { +impl From for A { fn from(v: u32) -> Self { A::One(v) } @@ -121,10 +118,10 @@ mod tests { fn test_add_from_impl_for_enum_complicated_path() { check_assist( add_from_impl_for_enum, - "enum A { <|>One(foo::bar::baz::Boo) }", - r#"enum A { One(foo::bar::baz::Boo) } + r#"enum A { <|>One(foo::bar::baz::Boo) }"#, + r#"enum A { <|>One(foo::bar::baz::Boo) } -<|>impl From for A { +impl From for A { fn from(v: foo::bar::baz::Boo) -> Self { A::One(v) } @@ -184,9 +181,9 @@ impl From for A { pub trait From { fn from(T) -> Self; }"#, - r#"enum A { One(u32), Two(String), } + r#"enum A { <|>One(u32), Two(String), } -<|>impl From for A { +impl From for A { fn from(v: u32) -> Self { A::One(v) } -- cgit v1.2.3