zed
zed copied to clipboard
git_panel: Add toggle for collapsing untracked files section
CLOSES https://github.com/zed-industries/zed/discussions/31856
Release Notes
- Improved
Git Panel: Collapsible Untracked Files Section The Git Panel now supports collapsing the untracked files section, making it easier to manage repositories with many generated or temporary files. What's New
Collapsible Untracked Section: Click the chevron icon next to "Untracked" header to expand/collapse untracked files Configurable Default State: Set collapse_untracked_files_section to true in your settings to have untracked files collapsed by default Keyboard Shortcut Support: Use the git_panel::ToggleUntrackedSection action to toggle visibility via keybinding
Configuration Add to your settings.json:
{
"git_panel": {
"collapse_untracked_files_section": true
}
}
Add to your keymap.json:
{
"bindings": {
"cmd-alt-u": "git_panel::ToggleUntrackedSection"
}
}
This feature is particularly useful for projects with build artifacts, node_modules, or other generated files that clutter the Git Panel view.
We require contributors to sign our Contributor License Agreement, and we don't have @n0x29a on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.
@cla-bot check
The cla-bot has been summoned, and re-checked this pull request!
| Warnings | |
|---|---|
| :warning: |
This PR is missing release notes. Please add a "Release Notes" section that describes the change:
If your change is not user-facing, you can use "N/A" for the entry:
|
Generated by :no_entry_sign: dangerJS against d536a1e33b63fec9e76cd507f82142e3a93dd03c
@n0x29a Thanks for the idea here!
If you have a lot of untracked files, I think a better fix would be to use git's features that ignore files: https://docs.github.com/en/get-started/git-basics/ignoring-files. Doing this will additionally mean that Zed will treat such files as "ignorable" - which is useful particularly when searching, but in general improves performance (as we don't recurse into node_modules when rendering the project panel for example).
@ConradIrwin I don't think that approach works very well if you have occasional untracked files. In this area Zed's usability is strictly worse for me vs other tools. I was looking forward to this PR getting merged; it's quite unfortunate that that won't happen. Note there's a couple feature requests in discussions to allow some further control.
To expand on the issues and differences here: while for "common" files definitely it makes sense to add them to .gitignore, I personally often end up with a few random one-off files in the repository. I've been using other tools in the past and they all handle this fairly gracefully. The problem with Zed is that it adds untracked files to the multibuffer the moment you open untracked changes. This is visually distracting and incurs performance issues for reasonably large files, e.g. you run some profiler, it generates a JSON data file that's a few megabytes, now every time I open the panel I get the JSON text inside it. I know there's been a recent change to mitigate this for very large files, but overall I feel like the combination of always showing untracked files and always adding "diffs" to the view, does not really work.
You can contrast this even with something as core as git: git diff will not show the contents of untracked files. So having occasional untracked files does not impede the usage of git diff (or basically any other git commands other than git add . which explicitly adds every single untracked file in the current folder).
Do you have suggestions for possible Zed improvements here, maybe not this PR exactly but something else? A setting that does not show untracked changes in the multibuffer perhaps, or a toggle to the same effect?
One thing we had talked about when building the feature was collapsing untracked files in the multibuffer by default. We didn't ship it like that, but I don't think we thought about it too hard. It might make a casual review of the diff less easy if you have to expand all the files, but it might also help in this situation.
Thanks for the suggestion! I submitted a PR to that effect https://github.com/zed-industries/zed/pull/32591