@@ -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,34 @@ 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 ! [ ] ;
243246
244- let entry = vfs:: loader:: Entry :: Files ( vec ! [ manifest. to_owned( ) ] ) ;
247+ if let Some ( manifest) = ws. manifest ( ) . map ( ManifestPath :: as_ref) {
248+ file_set_roots. push ( VfsPath :: from ( manifest. to_owned ( ) ) ) ;
249+ entries. push ( manifest. to_owned ( ) ) ;
250+ }
245251
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)
252+ // In case of detached files we do **not** look for a rust-analyzer.toml.
253+ if !matches ! ( ws. kind, ProjectWorkspaceKind :: DetachedFile { .. } ) {
254+ let ws_root = ws. workspace_root ( ) ;
255+ let ratoml_path = {
256+ let mut p = ws_root. to_path_buf ( ) ;
257+ p. push ( "rust-analyzer.toml" ) ;
258+ p
259+ } ;
260+ file_set_roots. push ( VfsPath :: from ( ratoml_path. to_owned ( ) ) ) ;
261+ entries. push ( ratoml_path. to_owned ( ) ) ;
262+ }
263+
264+ if !file_set_roots. is_empty ( ) {
265+ let entry = vfs:: loader:: Entry :: Files ( entries) ;
266+ res. watch . push ( res. load . len ( ) ) ;
267+ res. load . push ( entry) ;
268+ local_filesets. push ( fsc. len ( ) as u64 ) ;
269+ fsc. add_file_set ( file_set_roots)
270+ }
250271 }
251272
252273 let fsc = fsc. build ( ) ;
0 commit comments