@@ -8,7 +8,7 @@ use std::{sync::Arc, time::Instant};
88use crossbeam_channel:: { unbounded, Receiver , Sender } ;
99use flycheck:: FlycheckHandle ;
1010use ide:: { Analysis , AnalysisHost , Cancellable , Change , FileId } ;
11- use ide_db:: base_db:: { CrateId , FileLoader , SourceDatabase , SourceDatabaseExt } ;
11+ use ide_db:: base_db:: { CrateId , FileLoader , SourceDatabase } ;
1212use lsp_types:: { SemanticTokens , Url } ;
1313use parking_lot:: { Mutex , RwLock } ;
1414use proc_macro_api:: ProcMacroServer ;
@@ -176,9 +176,9 @@ impl GlobalState {
176176
177177 pub ( crate ) fn process_changes ( & mut self ) -> bool {
178178 let _p = profile:: span ( "GlobalState::process_changes" ) ;
179- let mut fs_refresh_changes = Vec :: new ( ) ;
180179 // A file was added or deleted
181180 let mut has_structure_changes = false ;
181+ let mut workspace_structure_change = None ;
182182
183183 let ( change, changed_files) = {
184184 let mut change = Change :: new ( ) ;
@@ -192,7 +192,7 @@ impl GlobalState {
192192 if let Some ( path) = vfs. file_path ( file. file_id ) . as_path ( ) {
193193 let path = path. to_path_buf ( ) ;
194194 if reload:: should_refresh_for_change ( & path, file. change_kind ) {
195- fs_refresh_changes . push ( ( path, file . file_id ) ) ;
195+ workspace_structure_change = Some ( path) ;
196196 }
197197 if file. is_created_or_deleted ( ) {
198198 has_structure_changes = true ;
@@ -227,11 +227,10 @@ impl GlobalState {
227227
228228 {
229229 let raw_database = self . analysis_host . raw_database ( ) ;
230- let workspace_structure_change =
231- fs_refresh_changes. into_iter ( ) . find ( |& ( _, file_id) | {
232- !raw_database. source_root ( raw_database. file_source_root ( file_id) ) . is_library
233- } ) ;
234- if let Some ( ( path, _) ) = workspace_structure_change {
230+ // FIXME: ideally we should only trigger a workspace fetch for non-library changes
231+ // but somethings going wrong with the source root business when we add a new local
232+ // crate see https://github.com/rust-lang/rust-analyzer/issues/13029
233+ if let Some ( path) = workspace_structure_change {
235234 self . fetch_workspaces_queue
236235 . request_op ( format ! ( "workspace vfs file change: {}" , path. display( ) ) ) ;
237236 }
0 commit comments