Skip to content

fix: only remove innermost manual folding range at cursor position - #304808

Closed
Yogeshwaran C (yogeshwaran-c) wants to merge 1 commit into
microsoft:mainfrom
yogeshwaran-c:fix/folding-remove-innermost-manual-range
Closed

Yogeshwaran C (yogeshwaran-c) wants to merge 1 commit into
microsoft:mainfrom
yogeshwaran-c:fix/folding-remove-innermost-manual-range

Conversation

@yogeshwaran-c

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix / Enhancement

What is the current behavior?

When the cursor is inside nested manual folding ranges and editor.removeManualFoldingRanges is executed, all manual folding ranges that intersect with the cursor line are removed. This makes it impossible to precisely remove just one specific manual range in a nested hierarchy — the user loses all containing manual ranges at once.

Closes #212599

What is the new behavior?

When executing editor.removeManualFoldingRanges with an empty selection (cursor only), only the innermost manual folding range containing the cursor is removed. Outer manual folding ranges are preserved.

For non-empty selections, the existing behavior of removing all manual ranges intersecting the selection is preserved.

Additional context

The implementation walks up the folding region tree from the innermost range found by findRange(), looking for the first region whose source is not FoldSource.provider (i.e., a manual/user-defined range). Only that specific range is targeted for removal. This matches the user expectation described in the issue: when the cursor is inside nested manual folds, running the command should peel off one layer at a time from the inside out.

When removing manual folding ranges with an empty selection (cursor
only), find and remove only the innermost manual folding range
containing the cursor, rather than all manual ranges that intersect
with the cursor line. This allows users to precisely remove a specific
manual range without losing outer manual ranges in a nested hierarchy.

For non-empty selections, the existing behavior of removing all manual
ranges intersecting the selection is preserved.

Closes microsoft#212599
@aeschli

Copy link
Copy Markdown
Contributor

Yogeshwaran C (@yogeshwaran-c) Thanks!
Can the fix be inside removeManualRanges?
Also please add a test.

@yogeshwaran-c

Copy link
Copy Markdown
Contributor Author

Superseded by #304793 which now combines both behaviors: innermost removal when cursor is on a manual range, and full removal when cursor is not on any manual range. This addresses both #212599 and #266597.

@aeschli Martin Aeschlimann (aeschli) removed this from the 1.114.0 milestone Mar 29, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators May 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[folding] Remove manual folding range should only remove most inner folding range

2 participants