From 553db8def1f0c05b3164d3188ecba943fad32b74 Mon Sep 17 00:00:00 2001 From: Ricardo Ander-Egg <37962604+polyrand@users.noreply.github.com> Date: Tue, 4 Nov 2025 05:28:33 +0100 Subject: [PATCH] Follow symlinks during file search (#4453) I have read the CLA Document and I hereby sign the CLA Closes #4452 This fixes a usability issue where users with symlinked folders in their working directory couldn't search those files using the `@` file search feature. ## Rationale The "bug" was in the file search implementation in `codex-rs/file-search/src/lib.rs`. The `WalkBuilder` was using default settings which don't follow symlinks, causing two related issues: 1. Partial search results: The `@` search would find symlinked directories but couldn't find files inside them 2. Inconsistent behavior: Users expect symlinked folders to behave like regular folders in search results. ## Root cause The `ignore` crate's `WalkBuilder` defaults to `.follow_links(false)` [[source](https://github.com/BurntSushi/ripgrep/blob/9802945e6342ec284633924cb7d8d3ce67204995/crates/ignore/src/walk.rs#L532)], so when traversing the file system, it would: - Detect symlinked directories as directory entries - But not traverse into them to index their contents - The `get_file_path` function would then filter out actual directories, leaving only the symlinked folder itself as a result Fix: Added `.follow_links(true)` to the `WalkBuilder` configuration, making the file search follow symlinks and index their contents just like regular directories. This change maintains backward compatibility since symlink following is generally expected behavior for file search tools, and it aligns with how users expect the `@` search feature to work. Co-authored-by: Eric Traut --- codex-rs/file-search/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codex-rs/file-search/src/lib.rs b/codex-rs/file-search/src/lib.rs index 0ae51210..0afc9ea6 100644 --- a/codex-rs/file-search/src/lib.rs +++ b/codex-rs/file-search/src/lib.rs @@ -159,6 +159,8 @@ pub fn run( .threads(num_walk_builder_threads) // Allow hidden entries. .hidden(false) + // Follow symlinks to search their contents. + .follow_links(true) // Don't require git to be present to apply to apply git-related ignore rules. .require_git(false); if !respect_gitignore {