assistant_slash_commands: Fix AI text thread path display bugs on Windows and all platforms (#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>
This commit is contained in:
Lay Sheth
2025-12-15 12:54:57 +05:30
committed by GitHub
parent 3db2d03bb3
commit 54c4302cdb
3 changed files with 19 additions and 85 deletions

1
Cargo.lock generated
View File

@@ -834,7 +834,6 @@ dependencies = [
"fs",
"futures 0.3.31",
"fuzzy",
"globset",
"gpui",
"html_to_markdown",
"http_client",