Fix stale Project Explorer entries after case-only rename on case-insensitive filesystems - #15699
Draft
warp-factories[bot] wants to merge 1 commit into
Draft
Conversation
…ensitive filesystems On case-insensitive filesystems (e.g. default macOS APFS), `Path::exists()` resolves case-insensitively. When the filesystem watcher's debouncer emits ambiguous `ModifyKind::Name(RenameMode::Any)` events for a case-only rename (e.g. `Foo` -> `foo`), both the old-case and new-case paths report as existing, so both are (incorrectly) treated as creates and neither as a delete. This leaves a stale, duplicate entry in the file tree. Add `path_exists_with_exact_case`, which checks the parent directory's actual listing for an exact-case match instead of relying on `Path::exists()`'s case-insensitive resolution, and use it at that call site. Fixes #15698
Author
|
This PR was generated with Warp. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Fixes a bug where renaming a folder so that only its letter case changes (e.g.
Company->company) on a case-insensitive filesystem (default macOS APFS) leaves a stale, duplicate entry in the Project Explorer file tree.Root cause: the filesystem watcher's debouncer (
crates/watcher) can emit ambiguousModifyKind::Name(RenameMode::Any)events for macOS renames, one per path involved. The code decided whether each such path was a create or a delete by callingPath::exists(). On a case-insensitive filesystem,Path::exists()resolves case-insensitively, so for a case-only rename both the old-case and new-case paths report as existing. Both then get treated as creates, and neither as a delete, leaving the stale old-case entry behind permanently (collapsing/re-expanding the tree does not clear it, matching the report).An ordinary rename (different name entirely) isn't affected, because the old path genuinely stops existing under any case.
Fix: added
path_exists_with_exact_case, which checks the parent directory's actual listing for an exact-case match instead of relying onPath::exists()'s case-insensitive resolution, and used it at that call site.Linked Issue
Fixes #15698
Testing
Added unit tests in
crates/watcher/src/lib_tests.rs:path_exists_with_exact_case_matches_the_exact_case_only/path_exists_with_exact_case_is_false_for_a_missing_path: directly test the new helper's exact-case matching contract.case_only_rename_is_treated_as_delete_of_old_case_and_create_of_new_case: an end-to-end test ofdeduplicate_and_merge_raw_notifier_eventsreproducing the reported scenario (old-case path routed todeleted, new-case path routed toadded).Ran
cargo test -p watcher,cargo clippy -p watcher --all-targets --all-features -- -D warnings, andrustfmt --checkon the changed files — all pass. Also verifiedcargo build/cargo clippystill succeed for the downstreamrepo_metadatacrate (with thelocal_fsfeature) that consumes this watcher code../script/run(not possible in this sandboxed, headless environment — validated via the automated tests above instead)Agent Mode
CHANGELOG-BUG-FIX: Fixed a bug where renaming a folder so only its letter case changes (e.g.
Company->company) on a case-insensitive filesystem left a stale duplicate entry in the Project Explorer file tree.