@@ -114,16 +114,18 @@ pub(super) fn patch_json_for_outdated_configs(json: &mut Value) {
114
114
}
115
115
116
116
// completion_addCallArgumentSnippets completion_addCallParenthesis -> completion_callable_snippets
117
- let res = match (
118
- copy. pointer ( "/completion/addCallArgumentSnippets" ) ,
119
- copy. pointer ( "/completion/addCallParenthesis" ) ,
120
- ) {
121
- ( Some ( Value :: Bool ( true ) ) , Some ( Value :: Bool ( true ) ) ) => json ! ( "fill_arguments" ) ,
122
- ( _, Some ( Value :: Bool ( true ) ) ) => json ! ( "add_parentheses" ) ,
123
- ( Some ( Value :: Bool ( false ) ) , Some ( Value :: Bool ( false ) ) ) => json ! ( "none" ) ,
124
- ( _, _) => return ,
125
- } ;
126
- merge ( json, json ! ( { "completion" : { "callable" : { "snippets" : res } } } ) ) ;
117
+ ' completion: {
118
+ let res = match (
119
+ copy. pointer ( "/completion/addCallArgumentSnippets" ) ,
120
+ copy. pointer ( "/completion/addCallParenthesis" ) ,
121
+ ) {
122
+ ( Some ( Value :: Bool ( true ) ) , Some ( Value :: Bool ( true ) ) ) => json ! ( "fill_arguments" ) ,
123
+ ( _, Some ( Value :: Bool ( true ) ) ) => json ! ( "add_parentheses" ) ,
124
+ ( Some ( Value :: Bool ( false ) ) , Some ( Value :: Bool ( false ) ) ) => json ! ( "none" ) ,
125
+ ( _, _) => break ' completion,
126
+ } ;
127
+ merge ( json, json ! ( { "completion" : { "callable" : { "snippets" : res } } } ) ) ;
128
+ }
127
129
128
130
// We need to do this due to the checkOnSave_enable -> checkOnSave change, as that key now can either be an object or a bool
129
131
// checkOnSave_* -> check_*
@@ -146,3 +148,23 @@ fn merge(dst: &mut Value, src: Value) {
146
148
( dst, src) => * dst = src,
147
149
}
148
150
}
151
+
152
+ #[ test]
153
+ fn check_on_save_patching ( ) {
154
+ let mut json = json ! ( { "checkOnSave" : { "overrideCommand" : "foo" } } ) ;
155
+ patch_json_for_outdated_configs ( & mut json) ;
156
+ assert_eq ! (
157
+ json,
158
+ json!( { "checkOnSave" : { "overrideCommand" : "foo" } , "check" : { "overrideCommand" : "foo" } } )
159
+ ) ;
160
+ }
161
+
162
+ #[ test]
163
+ fn check_on_save_patching_enable ( ) {
164
+ let mut json = json ! ( { "checkOnSave" : { "enable" : true , "overrideCommand" : "foo" } } ) ;
165
+ patch_json_for_outdated_configs ( & mut json) ;
166
+ assert_eq ! (
167
+ json,
168
+ json!( { "checkOnSave" : true , "check" : { "enable" : true , "overrideCommand" : "foo" } } )
169
+ ) ;
170
+ }
0 commit comments