Skip to content

Commit f1cb5b8

Browse files
bors[bot]matklad
andauthored
Merge #4392
4392: Add From should not move the cursor r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 parents 77d2eab + d9828a5 commit f1cb5b8

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

crates/ra_assists/src/handlers/add_from_impl_for_enum.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use ra_ide_db::RootDatabase;
2-
use ra_syntax::{
3-
ast::{self, AstNode, NameOwner},
4-
TextSize,
5-
};
2+
use ra_syntax::ast::{self, AstNode, NameOwner};
63
use stdx::format_to;
74
use test_utils::tested_by;
85

@@ -69,7 +66,6 @@ impl From<{0}> for {1} {{
6966
variant_name
7067
);
7168
edit.insert(start_offset, buf);
72-
edit.set_cursor(start_offset + TextSize::of("\n\n"));
7369
},
7470
)
7571
}
@@ -97,19 +93,20 @@ fn existing_from_impl(
9793

9894
#[cfg(test)]
9995
mod tests {
100-
use super::*;
96+
use test_utils::covers;
10197

10298
use crate::tests::{check_assist, check_assist_not_applicable};
103-
use test_utils::covers;
99+
100+
use super::*;
104101

105102
#[test]
106103
fn test_add_from_impl_for_enum() {
107104
check_assist(
108105
add_from_impl_for_enum,
109106
"enum A { <|>One(u32) }",
110-
r#"enum A { One(u32) }
107+
r#"enum A { <|>One(u32) }
111108
112-
<|>impl From<u32> for A {
109+
impl From<u32> for A {
113110
fn from(v: u32) -> Self {
114111
A::One(v)
115112
}
@@ -121,10 +118,10 @@ mod tests {
121118
fn test_add_from_impl_for_enum_complicated_path() {
122119
check_assist(
123120
add_from_impl_for_enum,
124-
"enum A { <|>One(foo::bar::baz::Boo) }",
125-
r#"enum A { One(foo::bar::baz::Boo) }
121+
r#"enum A { <|>One(foo::bar::baz::Boo) }"#,
122+
r#"enum A { <|>One(foo::bar::baz::Boo) }
126123
127-
<|>impl From<foo::bar::baz::Boo> for A {
124+
impl From<foo::bar::baz::Boo> for A {
128125
fn from(v: foo::bar::baz::Boo) -> Self {
129126
A::One(v)
130127
}
@@ -184,9 +181,9 @@ impl From<String> for A {
184181
pub trait From<T> {
185182
fn from(T) -> Self;
186183
}"#,
187-
r#"enum A { One(u32), Two(String), }
184+
r#"enum A { <|>One(u32), Two(String), }
188185
189-
<|>impl From<u32> for A {
186+
impl From<u32> for A {
190187
fn from(v: u32) -> Self {
191188
A::One(v)
192189
}

0 commit comments

Comments
 (0)