@@ -31,6 +31,23 @@ use crate::{
31
31
use ra_db:: ExternSourceId ;
32
32
use rustc_hash:: { FxHashMap , FxHashSet } ;
33
33
34
+ fn create_watcher ( workspaces : & [ ProjectWorkspace ] , options : & Options ) -> CheckWatcher {
35
+ workspaces
36
+ . iter ( )
37
+ . find_map ( |w| match w {
38
+ ProjectWorkspace :: Cargo { cargo, .. } => Some ( cargo) ,
39
+ ProjectWorkspace :: Json { .. } => None ,
40
+ } )
41
+ . map ( |cargo| {
42
+ let cargo_project_root = cargo. workspace_root ( ) . to_path_buf ( ) ;
43
+ Some ( CheckWatcher :: new ( & options. cargo_watch , cargo_project_root) )
44
+ } )
45
+ . unwrap_or_else ( || {
46
+ log:: warn!( "Cargo check watching only supported for cargo workspaces, disabling" ) ;
47
+ None
48
+ } )
49
+ }
50
+
34
51
#[ derive( Debug , Clone ) ]
35
52
pub struct Options {
36
53
pub publish_decorations : bool ,
@@ -168,20 +185,7 @@ impl WorldState {
168
185
change. set_crate_graph ( crate_graph) ;
169
186
170
187
// FIXME: Figure out the multi-workspace situation
171
- let check_watcher = workspaces
172
- . iter ( )
173
- . find_map ( |w| match w {
174
- ProjectWorkspace :: Cargo { cargo, .. } => Some ( cargo) ,
175
- ProjectWorkspace :: Json { .. } => None ,
176
- } )
177
- . map ( |cargo| {
178
- let cargo_project_root = cargo. workspace_root ( ) . to_path_buf ( ) ;
179
- Some ( CheckWatcher :: new ( & options. cargo_watch , cargo_project_root) )
180
- } )
181
- . unwrap_or_else ( || {
182
- log:: warn!( "Cargo check watching only supported for cargo workspaces, disabling" ) ;
183
- None
184
- } ) ;
188
+ let check_watcher = create_watcher ( & workspaces, & options) ;
185
189
186
190
let mut analysis_host = AnalysisHost :: new ( lru_capacity) ;
187
191
analysis_host. apply_change ( change) ;
@@ -207,6 +211,7 @@ impl WorldState {
207
211
) {
208
212
self . feature_flags = Arc :: new ( feature_flags) ;
209
213
self . analysis_host . update_lru_capacity ( lru_capacity) ;
214
+ self . check_watcher = create_watcher ( & self . workspaces , & options) ;
210
215
self . options = options;
211
216
}
212
217
0 commit comments