Skip to content

Commit cbd14e9

Browse files
committed
Auto merge of rust-lang#14801 - Veykril:process-changes-fix, r=Veykril
fix: Fix process-changes duplicating change events Should fix rust-lang/rust-analyzer#14791
2 parents daa03b0 + cace5bb commit cbd14e9

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

crates/rust-analyzer/src/global_state.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,15 @@ impl GlobalState {
196196
let (change, changed_files) = {
197197
let mut change = Change::new();
198198
let (vfs, line_endings_map) = &mut *self.vfs.write();
199-
let mut changed_files = vfs.take_changes();
199+
let changed_files = vfs.take_changes();
200200
if changed_files.is_empty() {
201201
return false;
202202
}
203203

204204
// We need to fix up the changed events a bit. If we have a create or modify for a file
205205
// id that is followed by a delete we actually skip observing the file text from the
206206
// earlier event, to avoid problems later on.
207-
for changed_file in &changed_files {
207+
for changed_file in changed_files {
208208
use vfs::ChangeKind::*;
209209

210210
file_changes
@@ -240,14 +240,13 @@ impl GlobalState {
240240
));
241241
}
242242

243-
changed_files.extend(
244-
file_changes
245-
.into_iter()
246-
.filter(|(_, (change_kind, just_created))| {
247-
!matches!((change_kind, just_created), (vfs::ChangeKind::Delete, true))
248-
})
249-
.map(|(file_id, (change_kind, _))| vfs::ChangedFile { file_id, change_kind }),
250-
);
243+
let changed_files: Vec<_> = file_changes
244+
.into_iter()
245+
.filter(|(_, (change_kind, just_created))| {
246+
!matches!((change_kind, just_created), (vfs::ChangeKind::Delete, true))
247+
})
248+
.map(|(file_id, (change_kind, _))| vfs::ChangedFile { file_id, change_kind })
249+
.collect();
251250

252251
// A file was added or deleted
253252
let mut has_structure_changes = false;

0 commit comments

Comments
 (0)