mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-26 13:54:06 +00:00
Add From should not move the cursor
This commit is contained in:
parent
c5c07c2a0a
commit
d9828a57fc
@ -1,8 +1,5 @@
|
|||||||
use ra_ide_db::RootDatabase;
|
use ra_ide_db::RootDatabase;
|
||||||
use ra_syntax::{
|
use ra_syntax::ast::{self, AstNode, NameOwner};
|
||||||
ast::{self, AstNode, NameOwner},
|
|
||||||
TextSize,
|
|
||||||
};
|
|
||||||
use stdx::format_to;
|
use stdx::format_to;
|
||||||
use test_utils::tested_by;
|
use test_utils::tested_by;
|
||||||
|
|
||||||
@ -69,7 +66,6 @@ impl From<{0}> for {1} {{
|
|||||||
variant_name
|
variant_name
|
||||||
);
|
);
|
||||||
edit.insert(start_offset, buf);
|
edit.insert(start_offset, buf);
|
||||||
edit.set_cursor(start_offset + TextSize::of("\n\n"));
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -97,19 +93,20 @@ fn existing_from_impl(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use test_utils::covers;
|
||||||
|
|
||||||
use crate::tests::{check_assist, check_assist_not_applicable};
|
use crate::tests::{check_assist, check_assist_not_applicable};
|
||||||
use test_utils::covers;
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_add_from_impl_for_enum() {
|
fn test_add_from_impl_for_enum() {
|
||||||
check_assist(
|
check_assist(
|
||||||
add_from_impl_for_enum,
|
add_from_impl_for_enum,
|
||||||
"enum A { <|>One(u32) }",
|
"enum A { <|>One(u32) }",
|
||||||
r#"enum A { One(u32) }
|
r#"enum A { <|>One(u32) }
|
||||||
|
|
||||||
<|>impl From<u32> for A {
|
impl From<u32> for A {
|
||||||
fn from(v: u32) -> Self {
|
fn from(v: u32) -> Self {
|
||||||
A::One(v)
|
A::One(v)
|
||||||
}
|
}
|
||||||
@ -121,10 +118,10 @@ mod tests {
|
|||||||
fn test_add_from_impl_for_enum_complicated_path() {
|
fn test_add_from_impl_for_enum_complicated_path() {
|
||||||
check_assist(
|
check_assist(
|
||||||
add_from_impl_for_enum,
|
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<foo::bar::baz::Boo> for A {
|
impl From<foo::bar::baz::Boo> for A {
|
||||||
fn from(v: foo::bar::baz::Boo) -> Self {
|
fn from(v: foo::bar::baz::Boo) -> Self {
|
||||||
A::One(v)
|
A::One(v)
|
||||||
}
|
}
|
||||||
@ -184,9 +181,9 @@ impl From<String> for A {
|
|||||||
pub trait From<T> {
|
pub trait From<T> {
|
||||||
fn from(T) -> Self;
|
fn from(T) -> Self;
|
||||||
}"#,
|
}"#,
|
||||||
r#"enum A { One(u32), Two(String), }
|
r#"enum A { <|>One(u32), Two(String), }
|
||||||
|
|
||||||
<|>impl From<u32> for A {
|
impl From<u32> for A {
|
||||||
fn from(v: u32) -> Self {
|
fn from(v: u32) -> Self {
|
||||||
A::One(v)
|
A::One(v)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user