Skip to content

Commit 3c6c1c9

Browse files
Don't use snippets
1 parent 8c10924 commit 3c6c1c9

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

crates/ide_assists/src/handlers/extract_type_alias.rs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
1313
// ```
1414
// ->
1515
// ```
16-
// type ${0:Type} = (u8, u8, u8);
16+
// type $0Type = (u8, u8, u8);
1717
//
1818
// struct S {
19-
// field: ${0:Type},
19+
// field: Type,
2020
// }
2121
// ```
2222
pub(crate) fn extract_type_alias(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
@@ -34,17 +34,12 @@ pub(crate) fn extract_type_alias(acc: &mut Assists, ctx: &AssistContext) -> Opti
3434
target,
3535
|builder| {
3636
builder.edit_file(ctx.frange.file_id);
37+
builder.replace(target, "Type");
3738
match ctx.config.snippet_cap {
3839
Some(cap) => {
39-
builder.replace_snippet(cap, target, "${0:Type}");
40-
builder.insert_snippet(
41-
cap,
42-
insert,
43-
format!("type ${{0:Type}} = {};\n\n", node),
44-
);
40+
builder.insert_snippet(cap, insert, format!("type $0Type = {};\n\n", node));
4541
}
4642
None => {
47-
builder.replace(target, "Type");
4843
builder.insert(insert, format!("type Type = {};\n\n", node));
4944
}
5045
}
@@ -80,10 +75,10 @@ struct S {
8075
}
8176
",
8277
r#"
83-
type ${0:Type} = u8;
78+
type $0Type = u8;
8479
8580
struct S {
86-
field: ${0:Type},
81+
field: Type,
8782
}
8883
"#,
8984
);
@@ -103,10 +98,10 @@ fn f() {
10398
r#"
10499
fn generic<T>() {}
105100
106-
type ${0:Type} = ();
101+
type $0Type = ();
107102
108103
fn f() {
109-
generic::<${0:Type}>();
104+
generic::<Type>();
110105
}
111106
"#,
112107
);
@@ -124,10 +119,10 @@ struct S {
124119
",
125120
r#"
126121
struct Vec<T> {}
127-
type ${0:Type} = Vec<u8>;
122+
type $0Type = Vec<u8>;
128123
129124
struct S {
130-
v: Vec<Vec<${0:Type}>>,
125+
v: Vec<Vec<Type>>,
131126
}
132127
"#,
133128
);
@@ -143,10 +138,10 @@ struct S {
143138
}
144139
",
145140
r#"
146-
type ${0:Type} = u8;
141+
type $0Type = u8;
147142
148143
struct S {
149-
field: (${0:Type},),
144+
field: (Type,),
150145
}
151146
"#,
152147
);

crates/ide_assists/src/tests/generated.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,10 @@ struct S {
338338
}
339339
"#####,
340340
r#####"
341-
type ${0:Type} = (u8, u8, u8);
341+
type $0Type = (u8, u8, u8);
342342
343343
struct S {
344-
field: ${0:Type},
344+
field: Type,
345345
}
346346
"#####,
347347
)

0 commit comments

Comments
 (0)