zC (close all folds recursively) only closes the innermost fold, not enclosing folds
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.2k
- Forks
- 1.5k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 6
Description
Describe the bug
zC is supposed to close the fold under the cursor and every fold enclosing it, all the way out to the outermost level, matching Vim's documented behavior. Instead, it only closes the single innermost fold directly containing the cursor. Folds enclosing that one are left open.
To Reproduce
- Open a file with at least two levels of nested foldable blocks, e.g.:
function outer() { function inner() { const x = 1; } } - Place the cursor on
const x = 1;(insideinner, with everything open). - Press
zC. inner's fold closes, butouter's fold around it stays open.
Expected behavior
zC should close inner and climb outward to also close outer, collapsing the whole nest in one press, regardless of how deep the cursor starts.
Environment
- Extension (VSCodeVim): reproduced against current
master - VSCode version: 1.128.0
- OS: Windows
Additional context
The root cause: zC dispatches VS Code's native editor.foldRecursively command, which only recurses into descendants of the fold at the cursor, not ancestors. zc (lowercase) already avoids this by using editor.fold with direction: "up" and a count-based levels argument, which correctly climbs outward. I have a small patch ready that applies that same mechanism to zC, and will open a PR referencing this issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the zC command dispatch and compare it with the existing zc implementation that uses editor.fold with direction "up" and levels. Reproduce the nested-fold scenario from the issue, then verify that zC closes the inner fold and every enclosing fold in one press.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100