Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit e80c7b8

Browse files
committed
Fix Cargo.toml filtering
Add implementation note Cleanup `is_relevant` usage
1 parent 636fd16 commit e80c7b8

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/actions/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ impl<'ctx> FileWatch<'ctx> {
240240
}
241241

242242
/// Returns if a file change is relevant to the files we actually wanted to watch
243+
// Implementation note: This is expected to be called a large number of times in a loop
244+
// so should be fast / avoid allocation.
243245
#[inline]
244246
pub fn is_relevant(&self, change: &FileEvent) -> bool {
245247
let path = change.uri.as_str();
@@ -250,7 +252,7 @@ impl<'ctx> FileWatch<'ctx> {
250252

251253
let local = &path[self.project_uri.len()..];
252254

253-
local == "/Cargo.lock" || local == "Cargo.toml"
255+
local == "/Cargo.lock" || local == "/Cargo.toml"
254256
|| local == "/target" && change.typ == FileChangeType::Deleted
255257
}
256258
}

src/actions/notifications.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,10 @@ impl<'a> NotificationAction<'a> for DidChangeWatchedFiles {
277277
let ctx = ctx.inited();
278278
let file_watch = FileWatch::new(&ctx);
279279

280-
// ignore irrelevant files from more spammy clients
281-
if !params.changes.iter().any(|c| file_watch.is_relevant(c)) {
282-
return Ok(());
280+
if params.changes.iter().any(|c| file_watch.is_relevant(c)) {
281+
ctx.build_current_project(BuildPriority::Cargo, out);
283282
}
284283

285-
ctx.build_current_project(BuildPriority::Cargo, out);
286-
287284
Ok(())
288285
}
289286
}

0 commit comments

Comments
 (0)