🧠 Smart Folding — WebStorm-Style Code Folding for VS CodeBring JetBrains/WebStorm's beloved folding experience to VS Code: single-line folds, a big clickable
🚀 Features🧩 WebStorm-style single-line foldsA collapsed block renders as one line — the closing bracket is folded away too:
🏷️ A real
|
| Command | What it does |
|---|---|
Smart Folding: Fold All (Remember Cursor) |
Folds everything and remembers your exact cursor + scroll |
Smart Folding: Unfold All (Restore Cursor) |
Unfolds everything and jumps back to your cursor |
Smart Folding: Smart Unfold (Reveal Cursor) |
Opens only the blocks containing your cursor |
Smart Folding: Smart Unfold Recursively |
Same, but opens the chain recursively |
Smart Folding: Copy (Whole Collapsed Blocks) |
Copies whole collapsed blocks (bound to Ctrl+C / Cmd+C) |
Smart Folding: Expand Folded Block on This Line |
Unfolds the block on the active line (badge hover action) |
💡 You don't have to use these commands — the built-in editor.foldAll / editor.unfoldAll / editor.unfold / editor.unfoldRecursively (with your own keybindings) are detected automatically.
⚙️ Settings
| Setting | Default | Description |
|---|---|---|
smartFolding.enhancedEllipsis |
true |
Show the clickable badge on collapsed blocks |
smartFolding.hideOpeningBracket |
true |
Render collapsed blocks as {...} (hides the real {) |
smartFolding.hideNativeFoldPlaceholder |
true |
🫥 Hides VS Code's built-in ⋯ collapsed-text indicator (makes editor.foldPlaceholderForeground transparent in your global color customizations) |
smartFolding.foldComments |
true |
Fold block comments, JSDoc & // comment runs (never single-line ones) |
smartFolding.commentPreview |
true |
Show the comment's first text line instead of ··· |
smartFolding.commentPreviewLength |
60 |
Max characters of the comment preview |
smartFolding.ellipsisBackground |
#46494e |
Badge background (base) |
smartFolding.ellipsisColor |
#9a9da5 |
Badge text color (base) |
smartFolding.ellipsisBackgroundDark / Light |
"" / #dfe1e5 |
Theme-specific background overrides |
smartFolding.ellipsisColorDark / Light |
"" / #6a6f77 |
Theme-specific text color overrides |
smartFolding.clickToExpand |
true |
Click a collapsed line to expand it |
smartFolding.clickLineToExpand |
false |
Click ANYWHERE on a collapsed line (not just the ··· badge) to expand it |
smartFolding.copyFoldedBlocks |
true |
Ctrl+C on a collapsed line copies the WHOLE hidden block, not just the visible row |
smartFolding.modifierClickExpandsRecursively |
true |
Alt+click a badge to expand recursively (modifier = editor.multiCursorModifier) |
smartFolding.singleLineFolding |
true |
Fold the closing bracket line too (WebStorm style) |
smartFolding.rememberCursorOnFoldAll |
true |
Remember cursor + scroll on Fold All |
smartFolding.restoreOnAnyUnfold |
true |
Restore the cursor after any unfold, any shortcut |
smartFolding.smartUnfold |
true |
Enable smart (focus) unfolding |
smartFolding.takeOverFolding |
true |
Be the sole folding provider (unified model verified against the tsserver parity suite + WebStorm single-line folds) |
smartFolding.languages |
JS/TS family | Languages the folding provider applies to |
Language coverage note (takeover): Smart Folding's scanner does not yet safely model the language-specific multiline literals of C, C++, C#, Java and PHP (raw strings, verbatim/interpolated strings, text blocks, heredoc). Those languages keep native VS Code folding even when listed in
smartFolding.languages— they are excluded from both the folding-provider registration and thedefaultFoldingRangeProvidertakeover until support lands.
🛠️ Build & Install
npm install
npx @vscode/vsce package # produces smart-folding-1.4.0.vsix
Then in VS Code: Extensions → ⋯ → Install from VSIX…
🧪 Development
npm run build # tsc -p ./
npm test # unit tests (node --test on out/test)
npm run test:parity # tsserver parity harness (lenient extras reporting)
npm run test:parity:strict # strict mode: unexpected extras fail (CI)
npm run test:integration # real extension-host tests (needs a display / xvfb)
The folding scanner and all detection logic live in src/core/folding.ts as pure, unit-tested functions. The parity fixtures in fixtures/parity/ are diffed against a real tsserver; intentional WebStorm divergences are recorded in fixtures/parity/allowlist.json.
📖 See TESTING.md for the detailed testing architecture (unit, parity, and integration tiers).
📄 License
MIT © 2026 SeyMi