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

Commit b905eab

Browse files
committed
Ignore irrelevant DidChangeWatchedFiles notifications
1 parent c635005 commit b905eab

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/actions/notifications.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,24 @@ impl<'a> Action<'a> for DidChangeWatchedFiles {
271271
}
272272

273273
impl<'a> NotificationAction<'a> for DidChangeWatchedFiles {
274-
fn handle<O: Output>(&mut self, _params: DidChangeWatchedFilesParams, ctx: &mut ActionContext, out: O) -> Result<(), ()> {
274+
fn handle<O: Output>(
275+
&mut self,
276+
params: DidChangeWatchedFilesParams,
277+
ctx: &mut ActionContext,
278+
out: O,
279+
) -> Result<(), ()> {
275280
trace!("on_cargo_change: thread: {:?}", thread::current().id());
281+
282+
// ignore irrelevant files from more spammy clients
283+
if !params.changes.iter().any(|change| {
284+
change.uri.as_str().ends_with("/Cargo.toml") ||
285+
change.uri.as_str().ends_with("/Cargo.lock") ||
286+
change.typ == FileChangeType::Deleted && change.uri.as_str().ends_with("/target")
287+
})
288+
{
289+
return Ok(());
290+
}
291+
276292
let ctx = ctx.inited();
277293
ctx.build_current_project(BuildPriority::Cargo, out);
278294

0 commit comments

Comments
 (0)