Description
VS Code Workspace Folders Flatten Hierarchical Structure in Explorer
Summary
VS Code flattens folder structure in the Explorer panel when using multi-root workspaces (.code-workspace
), even if the underlying file system has a hierarchical layout. This breaks expectations for developers working in large codebases where subtrees matter.
Reproduction Steps
Given the following file structure:
big-repo/
├── libs/
│ └── core/
│ └── CMakeLists.txt
├── tools/
│ └── analyzer/
│ └── analyze.cpp
├── apps/
│ └── test-runner/
│ └── main.cpp
And a workspace file:
{
"folders": [
{ "path": "libs/core" },
{ "path": "tools/analyzer" },
{ "path": "apps/test-runner" }
]
}
Current Behavior in VS Code
The Explorer shows:
core/
analyzer/
test-runner/
All folders appear as top-level roots, completely flattening the actual tree structure.
Expected Behavior
Folders should be shown hierarchically, respecting the full path:
libs/
core/
tools/
analyzer/
apps/
test-runner/
This would better match real-world workflows in large monorepos or platform codebases.
Proposal
Extend .code-workspace
to support hierarchical folder definitions to infer hierarchy based on path segments.
Why This Matters
- Developers in large codebases (e.g. monorepos, embedded platforms) often work on subsets of the project.
- Flattened folders lose the context and structure needed for understanding module ownership.
- File navigation becomes confusing when multiple folders named
core
,utils
, etc. appear at the root level.
Final remarks
The current flat folder view for workspaces breaks alignment with the file system and developer mental model. Enabling hierarchical structure would drastically improve usability for large and modular codebases.