Skip to content

Commit 3e73a46

Browse files
committed
fix: making tests compatible with new trimmed sel_range
1 parent 2bf5f14 commit 3e73a46

File tree

2 files changed

+26
-52
lines changed

2 files changed

+26
-52
lines changed

crates/ide_assists/src/handlers/extract_module.rs

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ use super::remove_unused_param::range_to_remove;
2828
// resolved.
2929
//
3030
// ```
31-
// $0
32-
// fn foo(name: i32) -> i32 {
31+
// $0fn foo(name: i32) -> i32 {
3332
// name + 1
34-
// }
35-
// $0
33+
// }$0
3634
//
3735
// fn bar(name: i32) -> i32 {
3836
// name + 2
@@ -939,8 +937,7 @@ $0pub struct PublicStruct {
939937
let _a = bar();
940938
}
941939
942-
$0
943-
struct PrivateStruct {
940+
$0struct PrivateStruct {
944941
inner: SomeType,
945942
}
946943
@@ -956,8 +953,7 @@ impl PrivateStruct {
956953
957954
fn bar() -> i32 {
958955
2
959-
}
960-
$0
956+
}$0
961957
}
962958
",
963959
r"
@@ -1019,11 +1015,9 @@ mod modname {
10191015
check_assist(
10201016
extract_module,
10211017
r"
1022-
$0
1023-
fn foo(name: i32) -> i32 {
1018+
$0fn foo(name: i32) -> i32 {
10241019
name + 1
1025-
}
1026-
$0
1020+
}$0
10271021
10281022
fn bar(name: i32) -> i32 {
10291023
name + 2
@@ -1049,15 +1043,13 @@ mod modname {
10491043
extract_module,
10501044
r"
10511045
mod impl_play {
1052-
$0
1053-
struct A {}
1046+
$0struct A {}
10541047
10551048
impl A {
10561049
pub fn new_a() -> i32 {
10571050
2
10581051
}
1059-
}
1060-
$0
1052+
}$0
10611053
10621054
fn a() {
10631055
let _a = A::new_a();
@@ -1097,11 +1089,9 @@ mod modname {
10971089
mod bar {
10981090
use super::foo::{PrivateStruct, PrivateStruct1};
10991091
1100-
$0
1101-
struct Strukt {
1092+
$0struct Strukt {
11021093
field: PrivateStruct,
1103-
}
1104-
$0
1094+
}$0
11051095
11061096
struct Strukt1 {
11071097
field: PrivateStruct1,
@@ -1145,11 +1135,9 @@ mod modname {
11451135
mod bar {
11461136
use super::foo::PrivateStruct;
11471137
1148-
$0
1149-
struct Strukt {
1138+
$0struct Strukt {
11501139
field: PrivateStruct,
1151-
}
1152-
$0
1140+
}$0
11531141
11541142
struct Strukt1 {
11551143
field: PrivateStruct,
@@ -1188,11 +1176,9 @@ mod modname {
11881176
mod bar {
11891177
pub struct PrivateStruct;
11901178
1191-
$0
1192-
struct Strukt {
1179+
$0struct Strukt {
11931180
field: PrivateStruct,
1194-
}
1195-
$0
1181+
}$0
11961182
11971183
struct Strukt1 {
11981184
field: PrivateStruct,
@@ -1227,13 +1213,11 @@ mod modname {
12271213
mod impl_play {
12281214
struct A {}
12291215
1230-
$0
1231-
impl A {
1216+
$0impl A {
12321217
pub fn new_a() -> i32 {
12331218
2
12341219
}
1235-
}
1236-
$0
1220+
}$0
12371221
12381222
fn a() {
12391223
let _a = A::new_a();
@@ -1274,13 +1258,11 @@ mod modname {
12741258
mod impl_play {
12751259
use super::foo::A;
12761260
1277-
$0
1278-
impl A {
1261+
$0impl A {
12791262
pub fn new_a() -> i32 {
12801263
2
12811264
}
1282-
}
1283-
$0
1265+
}$0
12841266
12851267
fn a() {
12861268
let _a = A::new_a();
@@ -1320,8 +1302,7 @@ mod modname {
13201302
mod impl_play2 {
13211303
trait JustATrait {}
13221304
1323-
$0
1324-
struct A {}
1305+
$0struct A {}
13251306
13261307
fn foo<T: JustATrait>(arg: T) -> T {
13271308
arg
@@ -1332,8 +1313,7 @@ impl JustATrait for A {}
13321313
fn bar() {
13331314
let a = A {};
13341315
foo(a);
1335-
}
1336-
$0
1316+
}$0
13371317
}
13381318
",
13391319
r"
@@ -1367,11 +1347,9 @@ mod modname {
13671347
extract_module,
13681348
r"
13691349
mod impl_play2 {
1370-
$0
1371-
mod impl_play {
1350+
$0mod impl_play {
13721351
pub struct A {}
1373-
}
1374-
$0
1352+
}$0
13751353
}
13761354
",
13771355
r"
@@ -1401,11 +1379,9 @@ mod modname {
14011379
}
14021380
14031381
fn main() {
1404-
$0
1405-
struct Strukt1 {
1382+
$0struct Strukt1 {
14061383
field: Strukt,
1407-
}
1408-
$0
1384+
}$0
14091385
}
14101386
//- /foo.rs
14111387
pub struct PrivateStruct;

crates/ide_assists/src/tests/generated.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,11 +531,9 @@ fn doctest_extract_module() {
531531
check_doc_test(
532532
"extract_module",
533533
r#####"
534-
$0
535-
fn foo(name: i32) -> i32 {
534+
$0fn foo(name: i32) -> i32 {
536535
name + 1
537-
}
538-
$0
536+
}$0
539537
540538
fn bar(name: i32) -> i32 {
541539
name + 2

0 commit comments

Comments
 (0)