Closed luisrudge closed 7 years ago
At the moment you can still use files.exclude
and search.exclude
. Still hope to support gitignore in the future.
@roblourens yeah, but it is kind of lame.. it is 2017 already, not 2004
The problem is that I work on a lot of projects at the same time and setting up files.exclude and search.exclude in addition everytime for every project would be really a pain since I already have all that stuff in my .gitignore for each project.
Since VSCode is such a gitrelated editor with the Git sidebar etc. I guess that should just be an inbuild option to toggle if you need it or not... No way to fetch the project folders gitignore and merge the arrays into the file/search exclude arrays?
I'm not a pro with typescript which is why I can't really help for now since I would have to read me in first, but otherwise I would like to contribute somehow so we can get this feature in.
This bug is super frustrating and actually causes me to lose work on a regular basis. To repro:
npm install -g electron-forge
git clone https://github.com/paulcbetts/trickline && cd trickline
npm i
## This creates a folder called 'out', which is ignored in my gitignore. However,
## it will have a copy of every source file in my project, with the same names
electron-forge package
code .
Now use Ctrl/Cmd-T to open a file. Whoops! You now have a 50% chance of editing the file in out
, which is at best annoying, causes you to constantly wonder "WHY DIDNT MY CHANGE DO ANYTHING????", and at worst, loses data when out
gets deleted by a git clean -xdf
along with your accidental changes.
VS Code understands Git in lots of other ways, there's no reason it can't parse gitignore. libgit2 will even do this on your behalf and help you out to do so.
@paulcbetts wow. that's shitty. I never thought of that. Not sure if anyone reads this issue though. Lots of people asking for it, but no one answering..
@paulcbetts In your case, you probably want to exclude out
via your tsconfig, since cmd+T is showing you files from the language service. That will also fix duplicates showing up in 'find all references', etc. Since files.exclude
doesn't currently impact those features, .gitignore
support as I'm imagining it wouldn't either. (And maybe I'm wrong, but I often want to use language service features on gitignored files like node_modules)
@paulcbetts @luisrudge @roblourens i'm using vscode exclusion, meanwhile this moves forward
In your case, you probably want to exclude out via your tsconfig, since cmd+T is showing you files from the language service (And maybe I'm wrong, but I often want to use language service features on gitignored files like node_modules)
@roblourens Cmd-T will really show you files in node_modules? I feel like there's got to be an extra layer of exclusion because that would be super noisy if it showed me every file in there
Hey after waiting for someone else to do it, I ended up putting together a small extension that copies your gitignore into your vscode workspace settings with one command: https://github.com/stubailo/vscode-ignore-gitignore
Let me know if this is useful, and looking forward to feedback and PRs! I've only tried it in a few projects but seems to work so far.
@paulcbetts regarding:
Cmd-T will really show you files in node_modules?
Cmd-T shows you all the symbols and not files in your workspace.
Regarding:
You now have a 50% chance of editing the file in out
The "out" folder includes the typescript source files in "out\trickline-win32-x64\resources\app\src" and the way the TypeScript language service is configured in the top-level "tsconfig.json" these files are part of the project context. They are therefore analyzed by TypeScript. To address this you should add an exclude
of "out" to your "tsconfig.json" as shown below:
{
"compilerOptions": {
"removeComments": false,
"preserveConstEnums": true,
"declaration": true,
"experimentalDecorators": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"noImplicitThis": true,
"noUnusedParameters": true,
"module": "commonjs",
"moduleResolution": "node",
"pretty": true,
"target": "es2015",
"jsx": "react",
"outDir": ".tmp/build"
},
"formatCodeOptions": {
"indentSize": 2,
"tabSize": 2
},
"types" : [
"node",
"electron"
],
"exclude": [
"out"
]
}
@egamma that's the whole point we're trying to get here... If we already have out
in our .gitignore file, why would I have to add it to the tsconfig file again?
Exactly, there should actually be more like a hierarchy for that.
.gitignore should always be the first ignore configuration to be loaded and should be merged with other vscode specific ignore configs.
Thanks @stubailo, https://github.com/stubailo/vscode-ignore-gitignore is a decent workaround for now but this shouldl really be in core.
I think IntelliJ IDEA nailed this:
.gitignore
d files and folders are grayed out by default in File explorer.gitignore
d files are automatically added to the projects "excluded" list
Searching for a file, there are matching files in non-ignored files/folders:
mobx.js
does not exist in the non-ignored files, switch to full-project search (ignored files are still grayed out)
Are there actually any plans on ever solving this issue? Is this something way more complicated?
I tried to wrap my head around the src (never worked with ts before) and it seems that hooking into the right place would make it possible to fetch the .gitignore from the projects cwd and add all array elements to the files.exclude
and search.exclude
.
I couldn't find the right place where this happens, even though I found multiple files loading data from the settings.json.
Is there anyone from Microsoft clarifying the status of this issue and if it's actually wanted by Microsoft?
Anyway looking forward for further discussions here.
Hoping to get it in for search in this release, via moving search to ripgrep: https://github.com/Microsoft/vscode/issues/19983
Once we have that, it might be possible to use ripgrep's highly optimized gitignore code to support it in the file explorer as well. The problems with putting the patterns in files.exclude
is that the syntax is not exactly the same, and that it doesn't support negative patterns, and performance for large gitignore files could also be an issue.
@roblourens sounds great and I understand the issues. I'm looking forward for the next release.
Ripgrep search landed in today's Insiders, with .gitignore support enabled by default! Set "search.useRipgrep": true
to try it out. There will likely be bugs... .gitignore support will be configurable later but I'm not sure how yet.
@roblourens thats great. Going to check it out and see if I can spot bugs for now.
@roblourens this is awesome, thank you!
@roblourens should we close this one given ripgrep work landed (release notes)?
But not file explorer yet. Issues like #13535 have been dupped into this one.
I wasn't sure since it has a lot of discussion about gitignore for the file explorer too. I think it makes sense to close this and start a new issue for that though.
The Ripgrep support is great, thank you for that! Can it be used for Cmd-P searching also? (It seems not, since I still get noise there if I don't configure the files.exclude
setting to exclude them).
(Sorry to pollute this issue with a somewhat unrelated question, please point me in the right direction and I'll shut up. 😛)
Not yet, I've got an issue for it - https://github.com/Microsoft/vscode/issues/24074
@roblourens just curious: why was this closed? as far as I can tell it was never resolved.
It was implemented for 1.11 - https://github.com/Microsoft/vscode/issues/78#issuecomment-290939774
@roblourens Why is this closed? It is solved for searchs yes, but it's not solved for explorer and there is not an option to exclude files in the explorer tree from gitignore. Is there any other issue for the explorer topic?
Edit: yes, you can use the ignore-gitignore extension, but I think that this should be integrated in the editor.
Graying out gitignored files is implemented in 1.18, and hiding them can be tracked by https://github.com/Microsoft/vscode/issues/23804
use .gitignore to know which files and folders not to search into (think
node_modules
orpackages
)