zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
48.3k stars 2.87k forks source link

Project Search not working #7087

Closed bklebe closed 2 months ago

bklebe commented 8 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

When I try to search in Project Search, I always get "No results: No results found in project for the provided query."

Environment

Zed: v0.119.21 (Zed) OS: macOS 14.3.0 Memory: 16 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

Screenshot 2024-01-30 at 10 36 48 Screenshot 2024-01-30 at 10 36 59

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.

zed.log

sivy commented 7 months ago

Hoping someone has a lead on this because I'm really liking Zed but not having full project search working is like having my left arm cut off, especially for large codebases.

bklebe commented 7 months ago

I feel the same way, Zed is great but I need full-project search. Had to switch back to VSCode until this is resolved.

Moshyfawn commented 7 months ago

I'm wondering why in the original screenshot, where the entry is listed in the file, the opened file is not selected in the tree view / project panel πŸ€”? It might have something to do with the issue at hand.

bklebe commented 7 months ago

I'm wondering why in the original screenshot, where the entry is listed in the file, the opened file is not selected in the tree view / project panel πŸ€”? It might have something to do with the issue at hand.

I gather there might be some sort of "project" that Zed needs to recognize in order to do search? But I couldn't figure out how to configure it properly. I've done File > Add Folder to Project... but it didn't fix the project search.

Moshyfawn commented 7 months ago

I just added a random huge Node.js project to an already open one and the search seems to have picked up the contents of the file. Maybe I should try to create an Elixir project to try to reproduce the issue.

bklebe commented 7 months ago

I can replicate this with a Python project as well, for what it's worth.

Moshyfawn commented 7 months ago

Is there anything from the setup described in #8419 that you might have in your project?

sivy commented 7 months ago

My python project is a simple project with no git repo or .gitignore setup.

bklebe commented 7 months ago

Is there anything from the setup described in #8419 that you might have in your project?

Aha! Yes, my $HOME is a Git repository itself, and all of my projects are nested under it.

Moshyfawn commented 7 months ago

Great, I'm glad we've at least identified the cause of your specific problem. I would suggest +πŸ‘ing the other issue and possibly adding any additional info you may have in the other thread.

It seems like others may have a different bottleneck, so I'll leave this issue open for now.

sivy commented 7 months ago

After moving my project out of $HOME and into my normal location, project search is working again.

JosephTLyons commented 7 months ago

For anyone following this thread for this bug, can you try the latest preview version and see if the issue persists?

https://zed.dev/releases/preview

bklebe commented 7 months ago

For anyone following this thread for this bug, can you try the latest preview version and see if the issue persists?

https://zed.dev/releases/preview

I just tried Zed 0.125.1 and I am still running into the same issue of everything being grayed out and search not working, unless I delete ~/.gitignore. One possible problem might be that I have been experimenting with non-Git VCS recently, namely Sapling and Jujutsu, which both use .gitignore but store their repo in .sl or .jj respectively (rather than .git). My $HOME repo is currently .sl. I tried hunting through the diffs to see if this could be the cause but couldn't find the specific commit that was supposed to fix this problem. Additionally, I can still replicate it even if I git init in $HOME, so it might not be related.

bklebe commented 7 months ago

Actually, if I run git init in a project repo, that fixes it, so it probably is related. I think I had the problem a bit backwards, sorry. Intuitively I would expect that the editor would only respect .gitignore in the open folder and not parents of the open folder. I believe this is how VSCode works, as I haven't encountered this issue in that editor, but reading the docs on gitignore (https://git-scm.com/docs/gitignore), it's not exactly how Git works, so maybe it would be better to recognize .sl and .jj as VCS folders instead.

bklebe commented 7 months ago

I suspect it's this code that would need to be updated: https://github.com/zed-industries/zed/blob/9c6a0d98eda255ec934cff1855f5ad1353eb0c86/crates/project_core/src/worktree.rs#L3351-L3354 Happy to look into fixing this myself since I realize non-Git VCS are a bit exotic, though not sure what the project thinks is the best way to go about it.

finscn commented 5 months ago

I have the same problem . so sad.

pineman commented 4 months ago

Also happening to me using git worktrees. My dir tree:

/.gitignore  <-- contains a single literal `*`, i.e., ignoring everything
 +-- proj1  <-- "main" project dir
   +-- .git  <-- git dir as usual
 +-- proj1_worktree  <-- created with `git worktree add ../proj1_worktree some_branch_name` inside proj1
   +-- .git  <-- just a file, as usual for a git worktree, with content like `gitdir: /full/path/proj1/.git/worktrees/some_branch_name`

When I open zed inside proj1_worktree, all files are greyed out in the Project Panel. I suspect because it's using the "root" .gitignore, and not proj1's .gitignore. When I remove the "root" .gitignore, it seems to work as expected. Thanks!

Quocker22 commented 4 months ago

In Zed, it won't automatically search when you type. After typing the keyword you want to search for within the project, then press > Enter to see the results if any.

Screenshot 2024-06-10 at 10 11 31
notpeter commented 2 months ago

I believe this may have been fixed as part of the work on these related issues.

If you are still experiencing this, please open a new issue with as much details as possible. Thanks all!