VSCodeVim / VSCodeVim/Vim

zC (close all folds recursively) only closes the innermost fold, not enclosing folds

Open
#10,061 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Open a file with at least two levels of nested foldable blocks, e.g.:
    function outer() {
      function inner() {
        const x = 1;
      }
    }
    
  2. Place the cursor on const x = 1; (inside inner, with everything open).
  3. Press zC.
  4. inner's fold closes, but outer'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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.