tomrijndorp / vscode-finditfaster

Find it, but faster! Fast file search for VS Code.
MIT License
299 stars 29 forks source link

Search files does not open files that are gitignored #31

Open juzerzarif opened 1 year ago

juzerzarif commented 1 year ago

Platform: MacOS Ventura 13.2.1 (Apple M1 Pro) VSCode version: 1.78.1

find-it-faster configuration:

{
  "find-it-faster.general.additionalSearchLocations": ["some-ignored-dir"]
}

With the above configuration when I add an ignored directory in FiF's search locations the "search files" command is able to find the files just fine but hitting Enter when focused on a filename doesn't open that file in the editor if the file is in the ignored directory. The directory I am trying is ignored via .gitignore but I am assuming this is true for any file that's ignored by the VSCode search...?

I would be interested in fixing this bug if someone could point me in the right direction.

tomrijndorp commented 1 year ago

Hi @juzerzarif, thanks for reporting! This was a tricky one. I only managed to reproduce this for the case where "some-ignored-dir" is a relative path. When the path is absolute, I don't have problems. Is this the same for you?

I'm wondering if the right "fix" for this, is to warn users that additionalSearchLocations should be an absolute path. FiF works slightly differently when there are multiple roots in the workspace, and this is roughly similar.

Honestly I'm having a hard time remembering why I even added to option to search additional locations, as opposed to just expecting users to add another folder to their workspace, so I'm also considering just ripping that option out at this point... Perhaps you could tell me for your case why using this option is preferable over adding a folder to the workspace? Thank you!

(And in the meantime, your problem can hopefully be solved by specifying the full path but I understand this is not as nice)

juzerzarif commented 1 year ago

My use case (might not be that common) is that I have a directory that a build tool will output that's gitignored but sometimes when I need to troubleshoot failures for that build tool I need to look through files in that directory so I've added it as an additional search location for FIF

juzerzarif commented 1 year ago

One suggestion that I had was maybe registering a key binding with fzf to toggle including ignored files in the search results but I'm not sure how FIF determines which files to include/exclude as search options or if FIF even has a concept of ignored files via stuff like .gitignore internally

Edit: Just saw the useGitIgnoreExcludes and useWorkspaceSearchExcludes settings so FIF definitely knows what files are being ignored. For my use case I can just switch these off/on depending on whether I'm troubleshooting a failure or not. Though a key bind in fzf might be nice still if you think it makes sense.

Edit 2: Nvm, setting useGitIgnoreExcludes and useWorkspaceSearchExcludes to false seems to result in no search options...?