Repository navigation
fix: only remove innermost manual folding range at cursor position - #304808
Closed
Yogeshwaran C (yogeshwaran-c) wants to merge 1 commit into
Closed
Yogeshwaran C (yogeshwaran-c) wants to merge 1 commit into
Yogeshwaran C (yogeshwaran-c) wants to merge 1 commit into
Conversation
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
Contributor
|
Yogeshwaran C (@yogeshwaran-c) Thanks! |
3 tasks
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.removeManualFoldingRangesis 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.removeManualFoldingRangeswith 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 notFoldSource.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.