File tree 1 file changed +33
-2
lines changed
crates/ide/src/inlay_hints
1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ fn variant_hints(
90
90
kind : InlayKind :: Discriminant ,
91
91
label,
92
92
text_edit : d. ok ( ) . map ( |val| {
93
- config. lazy_text_edit ( || TextEdit :: insert ( range. start ( ) , format ! ( "{eq_} {val}" ) ) )
93
+ config. lazy_text_edit ( || TextEdit :: insert ( range. end ( ) , format ! ( "{eq_} {val}" ) ) )
94
94
} ) ,
95
95
position : InlayHintPosition :: After ,
96
96
pad_left : false ,
@@ -102,8 +102,10 @@ fn variant_hints(
102
102
}
103
103
#[ cfg( test) ]
104
104
mod tests {
105
+ use expect_test:: expect;
106
+
105
107
use crate :: inlay_hints:: {
106
- tests:: { check_with_config, DISABLED_CONFIG } ,
108
+ tests:: { check_edit , check_with_config, DISABLED_CONFIG } ,
107
109
DiscriminantHints , InlayHintsConfig ,
108
110
} ;
109
111
@@ -210,4 +212,33 @@ enum Enum {
210
212
"# ,
211
213
) ;
212
214
}
215
+
216
+ #[ test]
217
+ fn edit ( ) {
218
+ check_edit (
219
+ InlayHintsConfig { discriminant_hints : DiscriminantHints :: Always , ..DISABLED_CONFIG } ,
220
+ r#"
221
+ #[repr(u8)]
222
+ enum Enum {
223
+ Variant(),
224
+ Variant1,
225
+ Variant2 {},
226
+ Variant3,
227
+ Variant5,
228
+ Variant6,
229
+ }
230
+ "# ,
231
+ expect ! [ [ r#"
232
+ #[repr(u8)]
233
+ enum Enum {
234
+ Variant() = 0,
235
+ Variant1 = 1,
236
+ Variant2 {} = 2,
237
+ Variant3 = 3,
238
+ Variant5 = 4,
239
+ Variant6 = 5,
240
+ }
241
+ "# ] ] ,
242
+ ) ;
243
+ }
213
244
}
You can’t perform that action at this time.
0 commit comments