-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Items in .gitignore
should still be searchable via file finder
#4745
Comments
Hey @mifopen, by chance, do you have the |
@JosephTLyons yes, 100% |
And I see where it could come from. But I've been using JetBrains IDEs for a decade and believe that "having smth in .gitignore" doesn't equal "excluded from the global project search". It's a separate setting (you can mark directories/files as "excluded") in JB IDEs and it feels natural. |
I think at the moment, that behavior is baked into zed on purpose, to prevent things like node_modules (and similar setups in other languages) from absolutely polluting the file finder results. That being said, we should probably consider some sort of setting here to give more flexibility into this: |
Totally agree |
.gitignore
should still be searchable via file finder
I agree as well but maybe add a option in the setting to override it. |
) Deals with https://github.com/zed-industries/community/issues/2347 Part of https://github.com/zed-industries/community/issues/1538 Now file finder will match all gitignored worktree entries. Zed does not traverse gitignored dirs by default, which means that not all gitignored files will be matches, but all that were toggled in project panel and all root non-directory gitignored entries will be now used, hopefully causing less questions. Release Notes: - Improved file finder to match all gitignored files that were added into worktrees (e.g. due to opening gitignored directories in project panel)
Piggybacking to share this related behaviour: in VS Code, doing "Find in folder" and searching for a query works if a folder is ignored, but in Zed that doesn't seem to be the case. Even if build/dist folders are grayed out in the editor, sometimes I want to make sure that something built correctly by searching for a string directly in an ignored folder. Similar thing if I'm learning how a node_module works, sometimes I want to perform a scoped search in the node_modules folder even though it's ignored |
I have this issue as well. I understand that excluding all files matched in Still, there are gitignored files which are legitimately useful to be able to open quickly. Some possible heuristics that could balance those two needs (at the cost of some complexity):
|
This is a relatively hard issue to tackle, if put in a generic form as "[any] items in First of all, Consider https://github.com/microsoft/vscode-eslint project as a web example, after installing the dependencies with
Also note that this repo is a relatively small project that does not include Angular or React + somethingX + .. in its State in ZedZed used to track all gitignored files at some point, but it was soon discovered that it becomes unresponsive relatively quickly due to the requirement to react on all related FS events and also [re]scan directories: zed/crates/worktree/src/worktree.rs Line 3460 in e77d313
Now, Zed does scan only the non-ignored directories: zed/crates/worktree/src/worktree.rs Line 2455 in e77d313
expand_entry -> refresh_entries_for_paths -> forcibly_load_paths chain of actions in the worktree — so, all currently expanded gitignored directories will be added into the same collection of worktree entries:zed/crates/worktree/src/worktree.rs Lines 135 to 136 in e77d313
and will be used when searching or displaying in the project panel, project search, file finder and various entry-related iterations. This way, Zed only "indices" and uses gitignored files if they are in the worktree/"project" root (as it gets opened by default) and all other directories that were open (e.g. due to autonavigating in the project tree to the entry corresponding to the editor opened). Zed does not use "gitignored files" concept too frequently: it shows a different icon in the project panel (ergo the whole "load gitignored directories via zed/crates/project/src/project.rs Lines 6299 to 6300 in e77d313
Design considerationsAt first, we need to understand what to display and how. So far, it feels that there are certain people that expect Zed showing an arbitrary The latter are simple to fix with #9760 or similar, but keeping the same design, how could former part be done? While traversing such file trees in realtime for fuzzy match queries does not sound possible, caching seems hard too due to invalidation? Neither of the current editors known to me seem to provide any similar functionality, but VSCode has a "whitelist" of directories to track — we could solve the issue with yet another config thing but that would not be very discoverable and might still slow things down overall on large enough One idea that seems worth exploring is to add more interactivity into file finder and propose to input gitignored roots first to start looking them up: match regularly before receiving |
Ohhh interesting.... Thank you so much for replying so quickly to this issue. I will take a look through the (incredibly extensive) comment that you left and I'll let you know if I have additional questions. |
I think excluding files from .gitignore generally is a good approach. 95% of my time searching files, I don't want to search in the files / folders included in the .gitignore. But I also frequently need to open files like .env that's not checked into git. So my proposed solution is a config that "forces" files /folders to be included in search, even though it's git ignored. Probably something like this:
So it acts sort of like a reverse gitignore, and can also use the same patterns used in .gitignore files for looking matched files / folders. |
I think the solution by @aarroisi should work. I also need to search some files which are ignored in .gitignore like configurations or some internal dependency, giving a configuration option to the user would give them more control over what they want to search, the default behaviour is okay but we must have an option to override it if needed! |
Another idea could be to reuse the already proven and mature "file_scan_exclusions": [
"!.env*"
// (...your other exclusions)
] Wherever the editor reads the This brings great flexibility and avoids introducing new settings. Examples:
|
I think we just need to allow to search file by relative path, ex: |
Has something like this been implemented? I am hoping for a quick way to open log files in the search project files dialog, that are currently ignored by git. This would be exactly what I need. |
I think @abejfehr's comment is worth more attention. If I explicitly list a .gitignored directory in my "include" filter I think it makes sense to override the exclusion of that directory and actually include files inside it when searching, even though it's part of my .gitignore |
E.g. in vscode my workaround is to use .ignore file to unignore the things that I want to see in quick search: .gitignore
.ignore
|
Check for existing issues
Describe the bug / provide steps to reproduce it
.env.local
in the open directoryenv
orlocal
Environment
Zed: v0.85.4 (stable)
OS: macOS 13.3.1
Memory: 16 GiB
Architecture: aarch64
If applicable, add mockups / screenshots to help explain present your vision of the feature
No response
If applicable, attach your
~/Library/Logs/Zed/Zed.log
file to this issue.If you only need the most recent lines, you can run the
zed: open log
command palette action to see the last 1000.No response
The text was updated successfully, but these errors were encountered: