File tree Expand file tree Collapse file tree 2 files changed +20
-14
lines changed Expand file tree Collapse file tree 2 files changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,12 @@ impl CheckWatcher {
5858 CheckWatcher { task_recv, cmd_send : Some ( cmd_send) , handle : Some ( handle) , shared }
5959 }
6060
61+ /// Returns a CheckWatcher that doesn't actually do anything
62+ pub fn dummy ( ) -> CheckWatcher {
63+ let shared = Arc :: new ( RwLock :: new ( CheckWatcherSharedState :: new ( ) ) ) ;
64+ CheckWatcher { task_recv : never ( ) , cmd_send : None , handle : None , shared }
65+ }
66+
6167 /// Schedule a re-start of the cargo check worker.
6268 pub fn update ( & self ) {
6369 if let Some ( cmd_send) = & self . cmd_send {
Original file line number Diff line number Diff line change @@ -132,20 +132,20 @@ impl WorldState {
132132 change. set_crate_graph ( crate_graph) ;
133133
134134 // FIXME: Figure out the multi-workspace situation
135- let check_watcher = {
136- let first_workspace = workspaces . first ( ) . unwrap ( ) ;
137- let cargo_project_root = match first_workspace {
138- ProjectWorkspace :: Cargo { cargo, .. } => cargo . workspace_root ( ) . to_path_buf ( ) ,
139- ProjectWorkspace :: Json { .. } => {
140- log :: warn! (
141- "Cargo check watching only supported for cargo workspaces, disabling"
142- ) ;
143- options. cargo_watch . enable = false ;
144- PathBuf :: new ( )
145- }
146- } ;
147- CheckWatcher :: new ( & options . cargo_watch , cargo_project_root )
148- } ;
135+ let check_watcher = workspaces
136+ . iter ( )
137+ . find_map ( |w| match w {
138+ ProjectWorkspace :: Cargo { cargo, .. } => Some ( cargo ) ,
139+ ProjectWorkspace :: Json { .. } => None ,
140+ } )
141+ . map ( | cargo| {
142+ let cargo_project_root = cargo . workspace_root ( ) . to_path_buf ( ) ;
143+ CheckWatcher :: new ( & options. cargo_watch , cargo_project_root )
144+ } )
145+ . unwrap_or_else ( || {
146+ log :: warn! ( "Cargo check watching only supported for cargo workspaces, disabling" ) ;
147+ CheckWatcher :: dummy ( )
148+ } ) ;
149149
150150 let mut analysis_host = AnalysisHost :: new ( lru_capacity, feature_flags) ;
151151 analysis_host. apply_change ( change) ;
You can’t perform that action at this time.
0 commit comments