Feature Request: Allow folding single physical lines that are soft-wrapped via wordWrap
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
## Feature Request
### Problem
VS Code's folding mechanism only works for multi-line blocks separated by hard newlines.
When a **single physical line** is long enough to trigger `editor.wordWrap` (soft visual wrapping):
- The line renders as multiple wrapped display lines on screen
- No folding arrow appears in the gutter
- Users cannot collapse this entire single physical line
### Steps to Reproduce
1. Editor settings:
```json
"editor.wordWrap": "bounded",
"editor.wordWrapColumn": 120
```
2. Create a file containing **only one physical line** (no manual hard line breaks):
```python
OPENAI_KEY = "sk-proj-1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
```
3. Resize editor window to trigger soft wrapping.
4. Observe: no fold arrow appears in the gutter for this line.
### Pain Points
1. Many scenarios use long single-line literals: API keys, tokens, long URLs, long string constants.
2. We enable wordWrap to eliminate horizontal scrollbars, but cannot hide these long lines.
3. Current mandatory workarounds:
- Modify source code to split the single line into a multi-line expression block to gain foldability.
- Install third-party extensions like Inline Fold for line-in text collapsing.
Neither workaround is ideal.
### Expected Behavior
Single physical lines that are visually soft-wrapped should support native folding:
1. Render fold indicator in the gutter for the single physical line
2. Click to collapse the whole physical line
3. Show shortened preview after collapse (e.g. `OPENAI_KEY = "..."`)
### Additional Context
The core limitation: folding logic only parses hard newline boundaries, and does not treat soft-wrapped display lines as foldable ranges.
Contributor guide
Assessment
This issue has not been assessed yet.