exclude-gitignored
Toggle the hiding of gitignored files in the Explorer.
vscode hides them itself through explorer.excludeGitIgnore, using git's own
ignore rules, but that setting is buried and not something you flip while you
work. This extension puts a single toggle on it.
The Explorer view
An "Exclude gitignored" section in the Explorer, next to Outline and Timeline,
lists the files that are hidden. excludeGitignored.viewVisibility decides when
it is there:
auto - while the files are hidden (default)
always - either way, so its title bar can turn the hiding on as well
off - never
The list keeps itself up to date: it follows the .gitignore files, the
setting, and the files appearing and disappearing on disk.
Two layouts, switched from its title bar:
- a tree, folders expanded, with one button that collapses and expands them
all. A folder that only happens to contain hidden files is greyed out,
because that folder stays visible in the Explorer, while a folder that is
hidden as a whole is not.
- a flat list of paths, files only, with the directory as a subdued suffix
The layout is kept in excludeGitignored.flatView. The counting is left to the
status bar. A last button opens the .gitignore behind it all, asking which
one in a workspace that has several - also available as
Exclude Gitignored: Open .gitignore from the command palette.
Toggling
Exclude Gitignored: Toggle Gitignored Files from the command palette,
ctrl+alt+g (cmd+alt+g on macOS), or the status bar entry:
$(eye-closed) 7 gitignored the seven are hidden, click to show them
$(eye) 7 gitignored the seven are shown, click to hide them
Set excludeGitignored.statusBarCounter to false to drop the number, or
excludeGitignored.statusBarItem to false to hide the entry altogether.
The count looks at up to 10000 files, beyond that it is shown with a
trailing +.
Tests
npm test runs the unit suite. It stubs the vscode API, so it needs no
extension host and runs in a few milliseconds. npm run test:integration runs
the suite inside vscode itself - from a terminal that vscode's extension host
spawned, unset ELECTRON_RUN_AS_NODE first, or the downloaded vscode starts as
plain node.
Acknowledgement
Credit goes to vscode-ignore-gitignore, and npxms.hide-gitignored, for inspiration.
License
MIT