@@ -180,18 +180,38 @@ impl ConfigTree {
180
180
181
181
fn read_only ( & self , file_id : FileId ) -> Result < Option < Arc < LocalConfigData > > , ConfigTreeError > {
182
182
let node_id = * self . ra_file_id_map . get ( & file_id) . ok_or ( ConfigTreeError :: NonExistent ) ?;
183
+ let stored = self . read_only_inner ( node_id) ?;
184
+ Ok ( stored. map ( |stored| {
185
+ if let Some ( client_config) = self . client_config . as_deref ( ) {
186
+ stored. clone_with_overrides ( client_config. local . clone ( ) ) . into ( )
187
+ } else {
188
+ stored
189
+ }
190
+ } ) )
191
+ }
192
+
193
+ fn read_only_inner (
194
+ & self ,
195
+ node_id : NodeId ,
196
+ ) -> Result < Option < Arc < LocalConfigData > > , ConfigTreeError > {
183
197
// indextree does not check this during get(), probably for perf reasons?
184
198
// get() is apparently only a bounds check
185
199
if node_id. is_removed ( & self . tree ) {
186
200
return Err ( ConfigTreeError :: Removed ) ;
187
201
}
188
202
let node = self . tree . get ( node_id) . ok_or ( ConfigTreeError :: NonExistent ) ?. get ( ) ;
189
- Ok ( self . computed [ node. computed ] . clone ( ) )
203
+ let stored = self . computed [ node. computed ] . clone ( ) ;
204
+ Ok ( stored)
190
205
}
191
206
192
207
fn compute ( & mut self , file_id : FileId ) -> Result < Arc < LocalConfigData > , ConfigTreeError > {
193
208
let node_id = * self . ra_file_id_map . get ( & file_id) . ok_or ( ConfigTreeError :: NonExistent ) ?;
194
- self . compute_inner ( node_id)
209
+ let computed = self . compute_inner ( node_id) ?;
210
+ Ok ( if let Some ( client_config) = self . client_config . as_deref ( ) {
211
+ computed. clone_with_overrides ( client_config. local . clone ( ) ) . into ( )
212
+ } else {
213
+ computed
214
+ } )
195
215
}
196
216
fn compute_inner ( & mut self , node_id : NodeId ) -> Result < Arc < LocalConfigData > , ConfigTreeError > {
197
217
if node_id. is_removed ( & self . tree ) {
@@ -403,6 +423,9 @@ mod tests {
403
423
r#"
404
424
[completion.autoimport]
405
425
enable = false
426
+ # will be overridden by client
427
+ [semanticHighlighting.strings]
428
+ enable = true
406
429
"# ,
407
430
) ;
408
431
@@ -413,8 +436,13 @@ mod tests {
413
436
// Normally you will filter these!
414
437
ra_toml_changes : vfs. take_changes ( ) ,
415
438
parent_changes,
416
- xdg_config_change : None ,
417
- client_change : None ,
439
+ client_change : Some ( Some ( Arc :: new ( ConfigInput {
440
+ local : crate :: config:: LocalConfigInput {
441
+ semanticHighlighting_strings_enable : Some ( false ) ,
442
+ ..Default :: default ( )
443
+ } ,
444
+ ..Default :: default ( )
445
+ } ) ) ) ,
418
446
} ;
419
447
420
448
dbg ! ( config_tree. apply_changes( changes, & vfs) ) ;
@@ -425,5 +453,7 @@ mod tests {
425
453
assert_eq ! ( local. completion_autoself_enable, false ) ;
426
454
// from crate_a
427
455
assert_eq ! ( local. completion_autoimport_enable, false ) ;
456
+ // from client
457
+ assert_eq ! ( local. semanticHighlighting_strings_enable, false ) ;
428
458
}
429
459
}
0 commit comments