Collapse Explorer folders without losing the item you are working on.
The extension adds a distinct Collapse Inactive Folders button beside VS Code's built-in Explorer controls. It collapses the tree completely—including inactive top-level folders in multi-root workspaces—then restores the focused item and its path.
Usage
Focus a file or folder in the Explorer, or keep working in a file-backed editor.
Click Collapse Inactive Folders in the Explorer title bar.
If the Explorer had focus, its focused row remains selected; a focused folder is reopened as well as its parent path. If an editor had focus, the active file becomes the preserved item. The same action is available from the Command Palette and the Explorer context menu. Context-menu use preserves every selected file or folder and leaves the clicked item focused.
Settings
Setting
Default
Description
collapseInactiveFolders.preserveFocusedItem
true
Preserve the item that had focus when the command started. Disable it to collapse everything. Explicit Explorer context-menu targets are always preserved.
Behavior and compatibility
In multi-root workspaces, inactive workspace roots collapse too; only roots containing a preserved item reopen.
A protected folder stays open, but unprotected expansion state below it is intentionally collapsed.
The title button and Command Palette preserve one focused item. Use the Explorer context menu to preserve a multi-selection.
Resources outside the current workspace and resource-less tabs such as terminals and webviews are ignored.
Multi-root workspaces, compact folders, local folders, WSL, Dev Containers, SSH, and other remote or virtual workspace providers use the same URI-based behavior.
No operating-system paths are parsed or normalized by the extension. VS Code owns workspace matching and Explorer reveal behavior, avoiding drive-letter, separator, UNC, and remote-authority inconsistencies.
Rapid follow-up invocations retain the latest target instead of being discarded.
VS Code Desktop on Windows, macOS, and Linux is supported, including remote desktop workflows. Standalone VS Code for the Web hosts are not currently supported.