@@ -89,7 +89,7 @@ impl ActionContext {
89
89
pub fn init < O : Output > (
90
90
& mut self ,
91
91
current_project : PathBuf ,
92
- init_options : & InitializationOptions ,
92
+ init_options : InitializationOptions ,
93
93
client_capabilities : lsp_data:: ClientCapabilities ,
94
94
out : & O ,
95
95
) -> Result < ( ) , ( ) > {
@@ -306,20 +306,27 @@ impl InitActionContext {
306
306
}
307
307
}
308
308
309
- fn init < O : Output > ( & self , init_options : & InitializationOptions , out : & O ) {
309
+ fn init < O : Output > ( & self , init_options : InitializationOptions , out : & O ) {
310
310
let current_project = self . current_project . clone ( ) ;
311
- let config = self . config . clone ( ) ;
312
- // Spawn another thread since we're shelling out to Cargo and this can
313
- // cause a non-trivial amount of time due to disk access
314
- thread:: spawn ( move || {
315
- let mut config = config. lock ( ) . unwrap ( ) ;
316
- if let Err ( e) = config. infer_defaults ( & current_project) {
317
- debug ! (
318
- "Encountered an error while trying to infer config defaults: {:?}" ,
319
- e
320
- ) ;
321
- }
322
- } ) ;
311
+
312
+ if let Some ( config) = init_options. settings . map ( |s| s. rust ) {
313
+ self . config . lock ( ) . unwrap ( ) . update ( config) ;
314
+ }
315
+
316
+ if self . config . lock ( ) . unwrap ( ) . needs_inference ( ) {
317
+ let config = Arc :: clone ( & self . config ) ;
318
+ // Spawn another thread since we're shelling out to Cargo and this can
319
+ // cause a non-trivial amount of time due to disk access
320
+ thread:: spawn ( move || {
321
+ let mut config = config. lock ( ) . unwrap ( ) ;
322
+ if let Err ( e) = config. infer_defaults ( & current_project) {
323
+ debug ! (
324
+ "Encountered an error while trying to infer config defaults: {:?}" ,
325
+ e
326
+ ) ;
327
+ }
328
+ } ) ;
329
+ }
323
330
324
331
if !init_options. omit_init_build {
325
332
self . build_current_project ( BuildPriority :: Cargo , out) ;
0 commit comments