@@ -12,13 +12,14 @@ use crate::{FileId, FunctionSignature};
1212
1313#[ derive( Clone , Debug , PartialEq , Eq ) ]
1414pub struct InlayConfig {
15- pub display_type : Vec < InlayKind > ,
15+ pub type_hints : bool ,
16+ pub parameter_hints : bool ,
1617 pub max_length : Option < usize > ,
1718}
1819
1920impl Default for InlayConfig {
2021 fn default ( ) -> Self {
21- Self { display_type : vec ! [ InlayKind :: TypeHint , InlayKind :: ParameterHint ] , max_length : None }
22+ Self { type_hints : true , parameter_hints : true , max_length : None }
2223 }
2324}
2425
@@ -64,7 +65,7 @@ fn get_param_name_hints(
6465 inlay_hint_opts : & InlayConfig ,
6566 expr : ast:: Expr ,
6667) -> Option < ( ) > {
67- if !inlay_hint_opts. display_type . contains ( & InlayKind :: ParameterHint ) {
68+ if !inlay_hint_opts. parameter_hints {
6869 return None ;
6970 }
7071
@@ -104,7 +105,7 @@ fn get_bind_pat_hints(
104105 inlay_hint_opts : & InlayConfig ,
105106 pat : ast:: BindPat ,
106107) -> Option < ( ) > {
107- if !inlay_hint_opts. display_type . contains ( & InlayKind :: TypeHint ) {
108+ if !inlay_hint_opts. type_hints {
108109 return None ;
109110 }
110111
@@ -223,7 +224,7 @@ fn get_fn_signature(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Option<
223224
224225#[ cfg( test) ]
225226mod tests {
226- use crate :: inlay_hints:: { InlayConfig , InlayKind } ;
227+ use crate :: inlay_hints:: InlayConfig ;
227228 use insta:: assert_debug_snapshot;
228229
229230 use crate :: mock_analysis:: single_file;
@@ -237,7 +238,7 @@ mod tests {
237238 let _x = foo(4, 4);
238239 }"# ,
239240 ) ;
240- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { display_type : vec! [ InlayKind :: ParameterHint ] , max_length: None } ) . unwrap( ) , @r###"
241+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { parameter_hints : true , type_hints : false , max_length: None } ) . unwrap( ) , @r###"
241242 [
242243 InlayHint {
243244 range: [106; 107),
@@ -261,7 +262,7 @@ mod tests {
261262 let _x = foo(4, 4);
262263 }"# ,
263264 ) ;
264- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { display_type : vec! [ ] , max_length: None } ) . unwrap( ) , @r###"[]"### ) ;
265+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { type_hints : false , parameter_hints : false , max_length: None } ) . unwrap( ) , @r###"[]"### ) ;
265266 }
266267
267268 #[ test]
@@ -273,7 +274,7 @@ mod tests {
273274 let _x = foo(4, 4);
274275 }"# ,
275276 ) ;
276- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { display_type : vec! [ InlayKind :: TypeHint ] , max_length: None } ) . unwrap( ) , @r###"
277+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { type_hints : true , parameter_hints : false , max_length: None } ) . unwrap( ) , @r###"
277278 [
278279 InlayHint {
279280 range: [97; 99),
@@ -810,7 +811,7 @@ fn main() {
810811}"# ,
811812 ) ;
812813
813- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { display_type : vec! [ InlayKind :: TypeHint , InlayKind :: ParameterHint ] , max_length : Some ( 8 ) } ) . unwrap( ) , @r###"
814+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { max_length : Some ( 8 ) , .. Default :: default ( ) } ) . unwrap( ) , @r###"
814815 [
815816 InlayHint {
816817 range: [74; 75),
@@ -1020,7 +1021,7 @@ fn main() {
10201021}"# ,
10211022 ) ;
10221023
1023- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { display_type : vec! [ InlayKind :: TypeHint , InlayKind :: ParameterHint ] , max_length : Some ( 8 ) } ) . unwrap( ) , @r###"
1024+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { max_length : Some ( 8 ) , .. Default :: default ( ) } ) . unwrap( ) , @r###"
10241025 []
10251026 "###
10261027 ) ;
@@ -1046,7 +1047,7 @@ fn main() {
10461047}"# ,
10471048 ) ;
10481049
1049- assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { display_type : vec! [ InlayKind :: TypeHint , InlayKind :: ParameterHint ] , max_length : Some ( 8 ) } ) . unwrap( ) , @r###"
1050+ assert_debug_snapshot ! ( analysis. inlay_hints( file_id, & InlayConfig { max_length : Some ( 8 ) , .. Default :: default ( ) } ) . unwrap( ) , @r###"
10501051 []
10511052 "###
10521053 ) ;
0 commit comments