assistant_slash_commands: Fix AI text thread path display bugs on Windows and all platforms#41880
assistant_slash_commands: Fix AI text thread path display bugs on Windows and all platforms#41880Veykril merged 2 commits intozed-industries:mainfrom
Conversation
|
Hey @CLoaKY233 ! Sorry that the review is taking longer than expected, I did not forge this PR but want to make sure that the glob normalization doesn't introduce any problems. Since the current changes are simply replacing let sanitized = SanitizedPath::new(glob).to_string();
let normalized = sanitized.replace('\\', "/");I'm worried that it might break, for example, in macOS, for a directory with a space, which could show up as something like |
|
There likely is a |
|
Thank you, @Veykril , help on the Windows side is much appreciated, as I don’t have access to a Windows development machine 🙂 Let me know if I can assist with anything macOS-related! |
|
Thanks for the thoughtful review and for investigating the Windows issues, |
|
@CLoaKY233 it looks like we fixed the underlying issue that this PR solves for. Can I go ahead and close this? |
Is the fix shipped in the latest version ? I am still facing the issue
.github being a foldable directory is changing the path of .zed |
|
I saw Lukas assigned himself so he might have more context. It might not have hit Stable just yet. |
|
Indeed this does not seem to be fixed entirely, I mustve missed something in testing. |
I would love to work on this issue if possible, finding the issue and adding a test for this particular condition. |
|
Can you check if the diff in #44687 works fully? I am not too familiar with text threads, but from what I just checked this should fix things properly. |
the issue is actually in the directory folding logic (used to compact chains like |
Add folded_directory_path to remember the currently folded directory and clear it when leaving that path, skipping empty directories, or after rendering a directory to prevent fold state leaking to unrelated entries.
|
Ah right, there are multiple issues at hand here are there. That folding one isn't windows specific I presume then right? (where as the listing one was?) |
I believe so, I could reproduce the folding directory issue on windows as well as linux, and the code is not platform specific. but also is this supposed to be like this ? ie. it's |
There was a problem hiding this comment.
Pull request overview
This PR fixes two bugs in the /file slash command: Windows path separator handling and folded directory path display issues. The core fix replaces a custom PathMatcher implementation with the standard util::paths::PathMatcher, which properly handles platform-specific path separators. Additionally, a new folded_directory_path tracking variable prevents folded directory names from leaking into sibling directories.
Key changes:
- Replaced custom
PathMatcherwithutil::paths::PathMatcherthat respects platform path styles - Added
folded_directory_pathtracking to properly reset folded states when exiting directory trees - Removed direct
globsetdependency as it's now only needed transitively throughutil
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/assistant_slash_commands/src/file_command.rs | Replaced custom PathMatcher with util::paths::PathMatcher; added folded_directory_path tracking variable and reset logic to prevent path leaking between sibling directories; removed custom_path_matcher module |
| crates/assistant_slash_commands/Cargo.toml | Removed direct globset dependency (now transitive through util) |
| Cargo.lock | Updated assistant_slash_commands dependencies to reflect globset removal |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I don't think its supposed to be like that, but thats a bug in the current release already, lets not mix that in here. |
|
The folding bug is now fixed— Should I add a test for this specific folding case? I can create one that verifies correct path display when folded directories (like Regarding the root directory naming inconsistency you mentioned, I'll keep that out of this PR as it's a separate existing issue. |
|
If you can come up with a test for that would be appreciated! I asked someone else internally to double check this change as I am not too familiar with text threads (my concern was the windows bug here) |
|
Thanks! |
…dows and all platforms (zed-industries#41880) ## Fix incorrect directory path folding in slash command file collection **Description:** This PR fixes a bug in the `collect_files` function where the directory folding logic (used to compact chains like `.github/workflows`) failed to reset its state when traversing out of a folded branch. **The Issue:** The `folded_directory_names` accumulator was persisting across loop iterations. If the traversal moved from a folded directory (e.g., `.github/workflows`) to a sibling directory (e.g., `.zed`), the sibling would incorrectly inherit the prefix of the previously folded path, resulting in incorrect paths like `.github/.zed`. **The Fix:** * Introduced `folded_directory_path` to track the specific path currently being folded. * Added a check to reset `folded_directory_names` whenever the traversal encounters an entry that is not a child of the currently folded path. * Ensured state is cleared immediately after a folded directory is rendered. **Release Notes:** - Fixed an issue where using slash commands to collect files would sometimes display incorrect directory paths (e.g., showing `.github/.zed` instead of `.zed`) when adjacent directories were automatically folded. --------- Co-authored-by: Lukas Wirth <lukas@zed.dev>


Fix incorrect directory path folding in slash command file collection
Description:
This PR fixes a bug in the
collect_filesfunction where the directory folding logic (used to compact chains like.github/workflows) failed to reset its state when traversing out of a folded branch.The Issue:
The
folded_directory_namesaccumulator was persisting across loop iterations. If the traversal moved from a folded directory (e.g.,.github/workflows) to a sibling directory (e.g.,.zed), the sibling would incorrectly inherit the prefix of the previously folded path, resulting in incorrect paths like.github/.zed.The Fix:
folded_directory_pathto track the specific path currently being folded.folded_directory_nameswhenever the traversal encounters an entry that is not a child of the currently folded path.Release Notes:
.github/.zedinstead of.zed) when adjacent directories were automatically folded.