@@ -15,7 +15,9 @@ use ide_db::{
15
15
} ;
16
16
use itertools:: Itertools ;
17
17
use 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
+ } ;
19
21
use span:: Span ;
20
22
use vfs:: { file_set:: FileSetConfig , loader:: Handle , AbsPath , AbsPathBuf , VfsPath } ;
21
23
@@ -238,15 +240,34 @@ impl ProjectFolders {
238
240
239
241
// register the workspace manifest as well, note that this currently causes duplicates for
240
242
// 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 ! [ ] ;
243
246
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
+ }
245
251
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
+ }
250
271
}
251
272
252
273
let fsc = fsc. build ( ) ;
0 commit comments