@@ -180,25 +180,15 @@ impl GlobalState {
180
180
// A file was added or deleted
181
181
let mut has_structure_changes = false ;
182
182
183
- let change = {
183
+ let ( change, changed_files ) = {
184
184
let mut change = Change :: new ( ) ;
185
185
let ( vfs, line_endings_map) = & mut * self . vfs . write ( ) ;
186
186
let changed_files = vfs. take_changes ( ) ;
187
187
if changed_files. is_empty ( ) {
188
188
return false ;
189
189
}
190
190
191
- for file in changed_files {
192
- if !file. is_created_or_deleted ( ) {
193
- // FIXME: https://github.com/rust-analyzer/rust-analyzer/issues/11357
194
- let crates = self . analysis_host . raw_database ( ) . relevant_crates ( file. file_id ) ;
195
- let crate_graph = self . analysis_host . raw_database ( ) . crate_graph ( ) ;
196
-
197
- if crates. iter ( ) . any ( |& krate| !crate_graph[ krate] . proc_macro . is_empty ( ) ) {
198
- self . proc_macro_changed = true ;
199
- }
200
- }
201
-
191
+ for file in & changed_files {
202
192
if let Some ( path) = vfs. file_path ( file. file_id ) . as_path ( ) {
203
193
let path = path. to_path_buf ( ) ;
204
194
if reload:: should_refresh_for_change ( & path, file. change_kind ) {
@@ -212,14 +202,11 @@ impl GlobalState {
212
202
213
203
let text = if file. exists ( ) {
214
204
let bytes = vfs. file_contents ( file. file_id ) . to_vec ( ) ;
215
- match String :: from_utf8 ( bytes) . ok ( ) {
216
- Some ( text) => {
217
- let ( text, line_endings) = LineEndings :: normalize ( text) ;
218
- line_endings_map. insert ( file. file_id , line_endings) ;
219
- Some ( Arc :: new ( text) )
220
- }
221
- None => None ,
222
- }
205
+ String :: from_utf8 ( bytes) . ok ( ) . and_then ( |text| {
206
+ let ( text, line_endings) = LineEndings :: normalize ( text) ;
207
+ line_endings_map. insert ( file. file_id , line_endings) ;
208
+ Some ( Arc :: new ( text) )
209
+ } )
223
210
} else {
224
211
None
225
212
} ;
@@ -229,10 +216,19 @@ impl GlobalState {
229
216
let roots = self . source_root_config . partition ( vfs) ;
230
217
change. set_roots ( roots) ;
231
218
}
232
- change
219
+ ( change, changed_files )
233
220
} ;
234
221
235
222
self . analysis_host . apply_change ( change) ;
223
+
224
+ let raw_database = & self . analysis_host . raw_database ( ) ;
225
+ self . proc_macro_changed =
226
+ changed_files. iter ( ) . filter ( |file| !file. is_created_or_deleted ( ) ) . any ( |file| {
227
+ let crates = raw_database. relevant_crates ( file. file_id ) ;
228
+ let crate_graph = raw_database. crate_graph ( ) ;
229
+
230
+ crates. iter ( ) . any ( |& krate| !crate_graph[ krate] . is_proc_macro )
231
+ } ) ;
236
232
true
237
233
}
238
234
0 commit comments