@@ -58,7 +58,7 @@ fn create_flycheck(workspaces: &[ProjectWorkspace], config: &FlycheckConfig) ->
58
58
#[ derive( Debug ) ]
59
59
pub struct WorldState {
60
60
pub config : Config ,
61
- pub roots : Vec < PathBuf > ,
61
+ pub local_roots : Vec < PathBuf > ,
62
62
pub workspaces : Arc < Vec < ProjectWorkspace > > ,
63
63
pub analysis_host : AnalysisHost ,
64
64
pub vfs : Arc < RwLock < Vfs > > ,
@@ -81,7 +81,6 @@ pub struct WorldSnapshot {
81
81
82
82
impl WorldState {
83
83
pub fn new (
84
- folder_roots : Vec < PathBuf > ,
85
84
workspaces : Vec < ProjectWorkspace > ,
86
85
lru_capacity : Option < usize > ,
87
86
exclude_globs : & [ Glob ] ,
@@ -93,19 +92,24 @@ impl WorldState {
93
92
let extern_dirs: FxHashSet < _ > =
94
93
workspaces. iter ( ) . flat_map ( ProjectWorkspace :: out_dirs) . collect ( ) ;
95
94
95
+ let mut local_roots = Vec :: new ( ) ;
96
96
let roots: Vec < _ > = {
97
97
let create_filter = |is_member| {
98
98
RustPackageFilterBuilder :: default ( )
99
99
. set_member ( is_member)
100
100
. exclude ( exclude_globs. iter ( ) . cloned ( ) )
101
101
. into_vfs_filter ( )
102
102
} ;
103
- folder_roots
103
+ workspaces
104
104
. iter ( )
105
- . map ( |path| RootEntry :: new ( path. clone ( ) , create_filter ( true ) ) )
106
- . chain ( workspaces. iter ( ) . flat_map ( ProjectWorkspace :: to_roots) . map ( |pkg_root| {
107
- RootEntry :: new ( pkg_root. path ( ) . to_owned ( ) , create_filter ( pkg_root. is_member ( ) ) )
108
- } ) )
105
+ . flat_map ( ProjectWorkspace :: to_roots)
106
+ . map ( |pkg_root| {
107
+ let path = pkg_root. path ( ) . to_owned ( ) ;
108
+ if pkg_root. is_member ( ) {
109
+ local_roots. push ( path. clone ( ) ) ;
110
+ }
111
+ RootEntry :: new ( path, create_filter ( pkg_root. is_member ( ) ) )
112
+ } )
109
113
. chain (
110
114
extern_dirs
111
115
. iter ( )
@@ -121,7 +125,7 @@ impl WorldState {
121
125
let mut extern_source_roots = FxHashMap :: default ( ) ;
122
126
for r in vfs_roots {
123
127
let vfs_root_path = vfs. root2path ( r) ;
124
- let is_local = folder_roots . iter ( ) . any ( |it| vfs_root_path. starts_with ( it) ) ;
128
+ let is_local = local_roots . iter ( ) . any ( |it| vfs_root_path. starts_with ( it) ) ;
125
129
change. add_root ( SourceRootId ( r. 0 ) , is_local) ;
126
130
change. set_debug_root_path ( SourceRootId ( r. 0 ) , vfs_root_path. display ( ) . to_string ( ) ) ;
127
131
@@ -178,7 +182,7 @@ impl WorldState {
178
182
analysis_host. apply_change ( change) ;
179
183
WorldState {
180
184
config,
181
- roots : folder_roots ,
185
+ local_roots ,
182
186
workspaces : Arc :: new ( workspaces) ,
183
187
analysis_host,
184
188
vfs : Arc :: new ( RwLock :: new ( vfs) ) ,
@@ -216,7 +220,7 @@ impl WorldState {
216
220
match c {
217
221
VfsChange :: AddRoot { root, files } => {
218
222
let root_path = self . vfs . read ( ) . root2path ( root) ;
219
- let is_local = self . roots . iter ( ) . any ( |r| root_path. starts_with ( r) ) ;
223
+ let is_local = self . local_roots . iter ( ) . any ( |r| root_path. starts_with ( r) ) ;
220
224
if is_local {
221
225
* roots_scanned += 1 ;
222
226
for ( file, path, text) in files {
0 commit comments