Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/biome_service/src/scanner/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ impl Watcher {
// `RenameMode::Any` and `ModifyKind::Any` need to be included as a catch-all.
// Without it, we'll miss events on Windows or macOS.
ModifyKind::Data(_) | ModifyKind::Name(RenameMode::Any) | ModifyKind::Any => {
Self::index_paths(workspace, paths)
// It's possible to receive Modify(Data) event after the file is removed on macOS.
if paths[0].exists() {
Self::index_paths(workspace, paths)
} else {
Self::unload_paths(workspace, paths)
}
}
_ => Ok(vec![]),
},
Expand Down
8 changes: 7 additions & 1 deletion crates/biome_service/src/scanner/watcher.tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ fn should_index_on_write_but_not_on_read() {

assert!(mock_bridge.watched_folders.pin().contains(project_path));

// It will take a while before the watcher become able to see events on Windows and macOS.
#[cfg(any(target_os = "windows", target_os = "macos"))]
sleep(Duration::from_secs(1));

fs::read(&file_path).expect("can read file");

// We'll try to test that a notification has _not_ been sent, so we need to
Expand Down Expand Up @@ -122,7 +126,9 @@ fn should_index_on_create_and_unload_on_delete() {

assert!(mock_bridge.watched_folders.pin().contains(project_path));

thread::sleep(Duration::from_millis(200));
// It will take a while before the watcher become able to see events on Windows and macOS.
#[cfg(any(target_os = "windows", target_os = "macos"))]
sleep(Duration::from_secs(1));

fs::write(&file_path, "import 'foo';").expect("can create file");

Expand Down
Loading