@@ -15,7 +15,9 @@ use ide_db::{
1515} ;
1616use itertools:: Itertools ;
1717use proc_macro_api:: { MacroDylib , ProcMacroServer } ;
18- use project_model:: { CargoConfig , ManifestPath , PackageRoot , ProjectManifest , ProjectWorkspace } ;
18+ use project_model:: {
19+ CargoConfig , ManifestPath , PackageRoot , ProjectManifest , ProjectWorkspace , ProjectWorkspaceKind ,
20+ } ;
1921use span:: Span ;
2022use vfs:: { file_set:: FileSetConfig , loader:: Handle , AbsPath , AbsPathBuf , VfsPath } ;
2123
@@ -238,15 +240,32 @@ impl ProjectFolders {
238240
239241 // register the workspace manifest as well, note that this currently causes duplicates for
240242 // non-virtual cargo workspaces! We ought to fix that
241- for manifest in workspaces. iter ( ) . filter_map ( |ws| ws. manifest ( ) . map ( ManifestPath :: as_ref) ) {
242- let file_set_roots: Vec < VfsPath > = vec ! [ VfsPath :: from( manifest. to_owned( ) ) ] ;
243+ for ws in workspaces. iter ( ) {
244+ let mut file_set_roots: Vec < VfsPath > = vec ! [ ] ;
245+ let mut entries = vec ! [ ] ;
246+ let mut register = false ;
247+
248+ if let Some ( manifest) = ws. manifest ( ) . map ( ManifestPath :: as_ref) {
249+ file_set_roots. push ( VfsPath :: from ( manifest. to_owned ( ) ) ) ;
250+ entries. push ( manifest. to_owned ( ) ) ;
251+ register = true ;
252+ }
243253
244- let entry = vfs:: loader:: Entry :: Files ( vec ! [ manifest. to_owned( ) ] ) ;
254+ // In case of detached files we do **not** look for a rust-analyzer.toml.
255+ if !matches ! ( ws. kind, ProjectWorkspaceKind :: DetachedFile { .. } ) {
256+ let ws_root = ws. workspace_root ( ) ;
257+ file_set_roots. push ( VfsPath :: from ( ws_root. to_owned ( ) ) ) ;
258+ entries. push ( ws_root. to_owned ( ) ) ;
259+ register = true ;
260+ }
245261
246- res. watch . push ( res. load . len ( ) ) ;
247- res. load . push ( entry) ;
248- local_filesets. push ( fsc. len ( ) as u64 ) ;
249- fsc. add_file_set ( file_set_roots)
262+ if register {
263+ let entry = vfs:: loader:: Entry :: Files ( entries) ;
264+ res. watch . push ( res. load . len ( ) ) ;
265+ res. load . push ( entry) ;
266+ local_filesets. push ( fsc. len ( ) as u64 ) ;
267+ fsc. add_file_set ( file_set_roots)
268+ }
250269 }
251270
252271 let fsc = fsc. build ( ) ;
0 commit comments