Skip to content

Symlink scan option - #53646

Merged
eholk merged 7 commits into
zed-industries:mainfrom
auwi-nordic:symlink_scan_option
Jun 1, 2026
Merged

Symlink scan option#53646
eholk merged 7 commits into
zed-industries:mainfrom
auwi-nordic:symlink_scan_option

Conversation

@auwi-nordic

Copy link
Copy Markdown
Contributor

Adds option to always search/scan symlinks for more thorough coverage of #41887 issue

This is a significant rewrite and more thoroughly reviewed and tested version of the old PR here:
#46344

The "never" option was removed from the old PR, since "expanded" is now the default. Perhaps "never" can be added as an option later if there's demand for it. Adding that option may resolve #48890 for instance.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable (significant impact with "always" option, but "expanded" is default)

Release Notes:

Introduces a new `scan_symlinks` setting that controls when Zed scans
the contents of symlinked directories.

Two options are supported:
- `expanded` (default): only scan symlinked directories after the user
  explicitly expands them in the project panel.
- `always`: follow all symbolic links and scan their contents on
  initial project load.

Release Notes:

- N/A
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 10, 2026
@zed-codeowner-coordinator
zed-codeowner-coordinator Bot requested a review from a team April 10, 2026 18:08
@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Apr 10, 2026
@zed-codeowner-coordinator
zed-codeowner-coordinator Bot requested review from eholk and smitbarmase and removed request for a team April 10, 2026 18:08
@auwi-nordic

Copy link
Copy Markdown
Contributor Author

@probably-neb FYI, pinging you since you were involved in the related issues/PRs

@auwi-nordic

Copy link
Copy Markdown
Contributor Author

I was reading #48890 and I think I may agree that symlinks within the project should be ignored. I explicitly tested for symlinks within the project for this PR (in addition to external symlinks). But it could perhaps be updated to completely disable the inclusion of symlinks within the project.

@pyronaur

pyronaur commented May 2, 2026

Copy link
Copy Markdown

@eholk or anyone else from Zed team:

Is there anything I can do to help move this forward? Being able to open files from symlinked directories is mission critical for me, having to expand trees manually just to be able to "cmd+P" to a file kind of defeats the purpose of "quick open".

I really don't want to go back to VSCode, but the lack of ability to configure multiple roots in Zed has really been hurting the entire time I've used Zed. I was hoping symlinks to be a reasonable workaround, but that turned out to be unusable too.

I would really appreciate a way to be able to add multiple directories from my fs to a single project that I can jump through/search through easily. I don't much care if it's symlinks or configuration of some sort, just as long as it can be done in some way.

@ercanozer

Copy link
Copy Markdown

@eholk @smitbarmase +1 here, critical for our team to be able to continue using Zed -

Possible to have some eyes on here?

@24samj

24samj commented May 13, 2026

Copy link
Copy Markdown

No updates on this? I feel this is such a critical feature that's missing rn. I too don't wanna go back to VS Code tbf. I can't just keep opening the project panel to literally find the file amongst hundreds of folders.

@injust

injust commented May 13, 2026

Copy link
Copy Markdown
Contributor

See #46469 for rationale behind a "never" option.

@pleibers

Copy link
Copy Markdown
Contributor

Please merge this, waiting for it forever already

@eholk

eholk commented May 15, 2026

Copy link
Copy Markdown
Contributor

@pyronaur:

I would really appreciate a way to be able to add multiple directories from my fs to a single project that I can jump through/search through easily. I don't much care if it's symlinks or configuration of some sort, just as long as it can be done in some way.

You are able to add multiple folders to a project already, by right clicking in a blank area in the project panel and choosing "Add Folders to Project..." Does this work for you?

I'm looking over this PR now...

@eholk eholk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Overall I think it looks like a nice improvement and directionally good. I was hoping to get this reviewed and merged before I head out for the weekend but unfortunately that didn't happen. Instead, here are some thoughts and comments.

There are a couple inline suggestions.

I think it's fine not to include a Never mode in this PR. It adds a lot of the plumbing needed to add one easily as a follow-up, so if there's enough interest we can do that.

It seems worth doing the work to skip within-project symlinks (or land it as a separate PR since that issue already exists without this PR).

Anyway, I'll finish the review next week. I'm happy to help address some of the suggestions I made too.

Comment thread crates/worktree/src/worktree.rs Outdated
Comment thread crates/worktree/src/worktree.rs Outdated
@auwi-nordic

Copy link
Copy Markdown
Contributor Author

It seems worth doing the work to skip within-project symlinks (or land it as a separate PR since that issue already exists without this PR).

Yeah, that seems like the correct order to fix it to me.

  1. Add option to skip within-project symlinks in a new PR
  2. If there's still a demand to never include symlinks in index, even for stuff you've explored in project panel, then add "Never" option

Anyway, I'll finish the review next week. I'm happy to help address some of the suggestions I made too.

I'll hold off on making any changes until then. If you want to just push suggestions feel free

@pyronaur

Copy link
Copy Markdown

@pyronaur:

I would really appreciate a way to be able to add multiple directories from my fs to a single project that I can jump through/search through easily. I don't much care if it's symlinks or configuration of some sort, just as long as it can be done in some way.

You are able to add multiple folders to a project already, by right clicking in a blank area in the project panel and choosing "Add Folders to Project..." Does this work for you?

I'm looking over this PR now...

@eholk That works even better! But where's the project configuration saved? I never use UI to open projects, I just do zed . when I'm in the right dir, and that doesn't re-open the project.

Symlinks was always a hack because last I tried, Zed didn't have a multi-root project config. I faintly remember that one variant worked, but it expanded all directories on open and I had to manually toggle them every time, and I jump around a lot, so doing that every time is also cumbersome.

@eholk

eholk commented May 20, 2026

Copy link
Copy Markdown
Contributor

@pyronaur - You can also use zed -a some_path to add some_path as a folder in your currently open workspace. You could probably script this to do something like

zed dir1
zed -a dir2
zed -a dir3

It might be worth considering a .zedproject file at some point that does this for you though.

@eholk

eholk commented May 20, 2026

Copy link
Copy Markdown
Contributor

I've been a little swamped this week but I should have time to get back to this starting tomorrow.

@pyronaur

Copy link
Copy Markdown

It might be worth considering a .zedproject file at some point that does this for you though.

🙏 Please this!

eholk added 3 commits May 22, 2026 12:48
# Conflicts:
#	crates/worktree/src/worktree.rs
Moves should_scan_directory from BackgroundScannerState to
BackgroundScanner so it can directly read self.settings.scan_symlinks
instead of receiving it as a parameter. This matches how every other
settings access in this file flows (e.g. is_path_excluded,
is_path_hidden, is_path_private).

Also collapses the predicate. The previous version introduced a
scan_external helper and a carve-out on the scanned_dirs branch so that
scan_symlinks was checked twice. The carve-out was not load-bearing:
should_scan_directory is a read-only predicate, so multiple
true-producing branches do not compound. Folding the external-Always
case into the first clause as one extra conjunct produces a single
symmetric `scannable` predicate and shrinks the diff from main.
@eholk

eholk commented May 22, 2026

Copy link
Copy Markdown
Contributor

I'm doing a Linux smoke test and assuming that goes well I'll merge this.

@eholk

eholk commented May 23, 2026

Copy link
Copy Markdown
Contributor

Hmm, unfortunately my Linux build doesn't seem to be following symbolic links at all. I think this will need some more investigation. Linux isn't my daily driver, so if someone else wants to dive in here and confirm whether it works for them, that would be super helpful!

@pleibers

Copy link
Copy Markdown
Contributor

I tried as well and running this zed version does not follow symlinks in the project search even when folders are expanded. (There shold not be a never option right?)

eholk added 2 commits June 1, 2026 13:04
Adds RealFs counterparts to test_scan_symlinks_always and
test_scan_symlinks_expanded. The existing tests use FakeFs, which does
not model fs::canonicalize against a real filesystem, so any
platform-specific differences in canonicalization or readdir behavior
slip past those tests.

A user reproduced behavior on Linux where the worktree does not appear
to follow symlinks at all, even with the symlinked directory manually
expanded — i.e. a regression of the fix in zed-industries#51382 that is only
observable on real filesystems. These tests are intended to surface
that class of regression in CI, gated on cfg(unix) so they run on the
Linux runner.
@eholk

eholk commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

@pleibers - Thanks for the confirmation. Out of curiosity, if you run a build off main (or just run the latest Stable/Preview/Nightly release), does it follow symlinks?

@eholk

eholk commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

After some more investigation, the Linux issue I'm seeing seems independent of this PR, so I think we're ready to merge this one and we can fix the other issues separately.

@eholk
eholk added this pull request to the merge queue Jun 1, 2026
Merged via the queue into zed-industries:main with commit 590aaaf Jun 1, 2026
32 checks passed
TomPlanche pushed a commit to TomPlanche/zed that referenced this pull request Jun 2, 2026
Adds option to always search/scan symlinks for more thorough coverage of
zed-industries#41887 issue

This is a significant rewrite and more thoroughly reviewed and tested
version of the old PR here:
zed-industries#46344

The "never" option was removed from the old PR, since "expanded" is now
the default. Perhaps "never" can be added as an option later if there's
demand for it. Adding that option may resolve zed-industries#48890 for instance.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable
(significant impact with "always" option, but "expanded" is default)

Release Notes:

- Add option choose between including expanded symlinks or include all
symlinks in project search (zed-industries#41887)

---------

Co-authored-by: Eric Holk <eric@zed.dev>
@prigaux

prigaux commented Jun 12, 2026

Copy link
Copy Markdown

NB: I wrongly expected this scan_symlinks option to have an impact on symlinked files, but it currently only impacts symlinked directories (as expected from the release notes, but not expected from this PR title and from the name of the option)

This was referenced Jun 18, 2026
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
Adds option to always search/scan symlinks for more thorough coverage of
zed-industries#41887 issue

This is a significant rewrite and more thoroughly reviewed and tested
version of the old PR here:
zed-industries#46344

The "never" option was removed from the old PR, since "expanded" is now
the default. Perhaps "never" can be added as an option later if there's
demand for it. Adding that option may resolve zed-industries#48890 for instance.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable
(significant impact with "always" option, but "expanded" is default)

Release Notes:

- Add option choose between including expanded symlinks or include all
symlinks in project search (zed-industries#41887)

---------

Co-authored-by: Eric Holk <eric@zed.dev>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
Adds option to always search/scan symlinks for more thorough coverage of
zed-industries#41887 issue

This is a significant rewrite and more thoroughly reviewed and tested
version of the old PR here:
zed-industries#46344

The "never" option was removed from the old PR, since "expanded" is now
the default. Perhaps "never" can be added as an option later if there's
demand for it. Adding that option may resolve zed-industries#48890 for instance.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable
(significant impact with "always" option, but "expanded" is default)

Release Notes:

- Add option choose between including expanded symlinks or include all
symlinks in project search (zed-industries#41887)

---------

Co-authored-by: Eric Holk <eric@zed.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search should never follow symlinks that point back into the project

8 participants