Files
zed/crates/editor
Dino df5cf7b718 editor: Add action to fold document at the current line's indentation (#66849)
## Summary

Even though the `editor: fold at level X` actions are useful, when I do
want to use those I end up having to figure out the level myself, for
example, when wanting to fold all variants of an `enum` or all
methods/functions in an `impl` block.

As such, this Pull Request introduces a `editor: fold at current
indentation level` action which will take the current line's indentation
level and fold the whole document at that level. This makes it super
easy to, for example, place the cursor in a variant of an `enum`, call
the action and have all the variants visible on screen, regardless of
whether the variants have extra arguments. Refer to the recording below
for an example.

## Testing

Tested both manually, as shown in the recording below, as well as
introduced the following tests:

* `editor::editor_tests::test_fold_at_current_level`
*
`editor::editor_tests::test_fold_at_current_level_is_column_independent_with_injection`
* `editor::editor_tests::test_fold_at_current_level_with_tabs`
*
`editor::editor_tests::test_fold_at_current_level_with_tabs_and_soft_tab_settings`
*
`editor::editor_tests::test_fold_at_current_level_with_spaces_and_hard_tab_settings`
*
`editor::editor_tests::test_fold_at_current_level_with_mixed_indentation`
* `editor::editor_tests::test_fold_at_current_level_ignores_empty_lines`
* `editor::editor_tests::test_fold_at_current_level_on_space_only_lines`
* `editor::editor_tests::test_fold_at_current_level_on_tab_only_lines`
*
`editor::editor_tests::test_fold_at_current_level_with_multiple_cursors`

### Recording


https://github.com/user-attachments/assets/20334b35-c14e-49b9-a2a5-63958709f40e

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- Added `editor: fold at current indentation level` to allow folding the
whole document at the current line's indentation level
2026-11-17 20:57:13 +00:00
..