Detailed changes
@@ -527,15 +527,15 @@
"ctrl-k ctrl-l": "editor::ToggleFold",
"ctrl-k ctrl-[": "editor::FoldRecursive",
"ctrl-k ctrl-]": "editor::UnfoldRecursive",
- "ctrl-k ctrl-1": ["editor::FoldAtLevel", 1],
- "ctrl-k ctrl-2": ["editor::FoldAtLevel", 2],
- "ctrl-k ctrl-3": ["editor::FoldAtLevel", 3],
- "ctrl-k ctrl-4": ["editor::FoldAtLevel", 4],
- "ctrl-k ctrl-5": ["editor::FoldAtLevel", 5],
- "ctrl-k ctrl-6": ["editor::FoldAtLevel", 6],
- "ctrl-k ctrl-7": ["editor::FoldAtLevel", 7],
- "ctrl-k ctrl-8": ["editor::FoldAtLevel", 8],
- "ctrl-k ctrl-9": ["editor::FoldAtLevel", 9],
+ "ctrl-k ctrl-1": "editor::FoldAtLevel_1",
+ "ctrl-k ctrl-2": "editor::FoldAtLevel_2",
+ "ctrl-k ctrl-3": "editor::FoldAtLevel_3",
+ "ctrl-k ctrl-4": "editor::FoldAtLevel_4",
+ "ctrl-k ctrl-5": "editor::FoldAtLevel_5",
+ "ctrl-k ctrl-6": "editor::FoldAtLevel_6",
+ "ctrl-k ctrl-7": "editor::FoldAtLevel_7",
+ "ctrl-k ctrl-8": "editor::FoldAtLevel_8",
+ "ctrl-k ctrl-9": "editor::FoldAtLevel_9",
"ctrl-k ctrl-0": "editor::FoldAll",
"ctrl-k ctrl-j": "editor::UnfoldAll",
"ctrl-space": "editor::ShowCompletions",
@@ -582,15 +582,15 @@
"cmd-k cmd-l": "editor::ToggleFold",
"cmd-k cmd-[": "editor::FoldRecursive",
"cmd-k cmd-]": "editor::UnfoldRecursive",
- "cmd-k cmd-1": ["editor::FoldAtLevel", 1],
- "cmd-k cmd-2": ["editor::FoldAtLevel", 2],
- "cmd-k cmd-3": ["editor::FoldAtLevel", 3],
- "cmd-k cmd-4": ["editor::FoldAtLevel", 4],
- "cmd-k cmd-5": ["editor::FoldAtLevel", 5],
- "cmd-k cmd-6": ["editor::FoldAtLevel", 6],
- "cmd-k cmd-7": ["editor::FoldAtLevel", 7],
- "cmd-k cmd-8": ["editor::FoldAtLevel", 8],
- "cmd-k cmd-9": ["editor::FoldAtLevel", 9],
+ "cmd-k cmd-1": "editor::FoldAtLevel_1",
+ "cmd-k cmd-2": "editor::FoldAtLevel_2",
+ "cmd-k cmd-3": "editor::FoldAtLevel_3",
+ "cmd-k cmd-4": "editor::FoldAtLevel_4",
+ "cmd-k cmd-5": "editor::FoldAtLevel_5",
+ "cmd-k cmd-6": "editor::FoldAtLevel_6",
+ "cmd-k cmd-7": "editor::FoldAtLevel_7",
+ "cmd-k cmd-8": "editor::FoldAtLevel_8",
+ "cmd-k cmd-9": "editor::FoldAtLevel_9",
"cmd-k cmd-0": "editor::FoldAll",
"cmd-k cmd-j": "editor::UnfoldAll",
// Using `ctrl-space` / `ctrl-shift-space` in Zed requires disabling the macOS global shortcut.
@@ -536,15 +536,15 @@
"ctrl-k ctrl-l": "editor::ToggleFold",
"ctrl-k ctrl-[": "editor::FoldRecursive",
"ctrl-k ctrl-]": "editor::UnfoldRecursive",
- "ctrl-k ctrl-1": ["editor::FoldAtLevel", 1],
- "ctrl-k ctrl-2": ["editor::FoldAtLevel", 2],
- "ctrl-k ctrl-3": ["editor::FoldAtLevel", 3],
- "ctrl-k ctrl-4": ["editor::FoldAtLevel", 4],
- "ctrl-k ctrl-5": ["editor::FoldAtLevel", 5],
- "ctrl-k ctrl-6": ["editor::FoldAtLevel", 6],
- "ctrl-k ctrl-7": ["editor::FoldAtLevel", 7],
- "ctrl-k ctrl-8": ["editor::FoldAtLevel", 8],
- "ctrl-k ctrl-9": ["editor::FoldAtLevel", 9],
+ "ctrl-k ctrl-1": "editor::FoldAtLevel_1",
+ "ctrl-k ctrl-2": "editor::FoldAtLevel_2",
+ "ctrl-k ctrl-3": "editor::FoldAtLevel_3",
+ "ctrl-k ctrl-4": "editor::FoldAtLevel_4",
+ "ctrl-k ctrl-5": "editor::FoldAtLevel_5",
+ "ctrl-k ctrl-6": "editor::FoldAtLevel_6",
+ "ctrl-k ctrl-7": "editor::FoldAtLevel_7",
+ "ctrl-k ctrl-8": "editor::FoldAtLevel_8",
+ "ctrl-k ctrl-9": "editor::FoldAtLevel_9",
"ctrl-k ctrl-0": "editor::FoldAll",
"ctrl-k ctrl-j": "editor::UnfoldAll",
"ctrl-space": "editor::ShowCompletions",
@@ -456,6 +456,33 @@ actions!(
Fold,
/// Folds all foldable regions in the editor.
FoldAll,
+ /// Folds all code blocks at indentation level 1.
+ #[action(name = "FoldAtLevel_1")]
+ FoldAtLevel1,
+ /// Folds all code blocks at indentation level 2.
+ #[action(name = "FoldAtLevel_2")]
+ FoldAtLevel2,
+ /// Folds all code blocks at indentation level 3.
+ #[action(name = "FoldAtLevel_3")]
+ FoldAtLevel3,
+ /// Folds all code blocks at indentation level 4.
+ #[action(name = "FoldAtLevel_4")]
+ FoldAtLevel4,
+ /// Folds all code blocks at indentation level 5.
+ #[action(name = "FoldAtLevel_5")]
+ FoldAtLevel5,
+ /// Folds all code blocks at indentation level 6.
+ #[action(name = "FoldAtLevel_6")]
+ FoldAtLevel6,
+ /// Folds all code blocks at indentation level 7.
+ #[action(name = "FoldAtLevel_7")]
+ FoldAtLevel7,
+ /// Folds all code blocks at indentation level 8.
+ #[action(name = "FoldAtLevel_8")]
+ FoldAtLevel8,
+ /// Folds all code blocks at indentation level 9.
+ #[action(name = "FoldAtLevel_9")]
+ FoldAtLevel9,
/// Folds all function bodies in the editor.
FoldFunctionBodies,
/// Folds the current code block and all its children.
@@ -18170,6 +18170,87 @@ impl Editor {
self.fold_creases(to_fold, true, window, cx);
}
+ pub fn fold_at_level_1(
+ &mut self,
+ _: &actions::FoldAtLevel1,
+ window: &mut Window,
+ cx: &mut Context<Self>,
+ ) {
+ self.fold_at_level(&actions::FoldAtLevel(1), window, cx);
+ }
+
+ pub fn fold_at_level_2(
+ &mut self,
+ _: &actions::FoldAtLevel2,
+ window: &mut Window,
+ cx: &mut Context<Self>,
+ ) {
+ self.fold_at_level(&actions::FoldAtLevel(2), window, cx);
+ }
+
+ pub fn fold_at_level_3(
+ &mut self,
+ _: &actions::FoldAtLevel3,
+ window: &mut Window,
+ cx: &mut Context<Self>,
+ ) {
+ self.fold_at_level(&actions::FoldAtLevel(3), window, cx);
+ }
+
+ pub fn fold_at_level_4(
+ &mut self,
+ _: &actions::FoldAtLevel4,
+ window: &mut Window,
+ cx: &mut Context<Self>,
+ ) {
+ self.fold_at_level(&actions::FoldAtLevel(4), window, cx);
+ }
+
+ pub fn fold_at_level_5(
+ &mut self,
+ _: &actions::FoldAtLevel5,
+ window: &mut Window,
+ cx: &mut Context<Self>,
+ ) {
+ self.fold_at_level(&actions::FoldAtLevel(5), window, cx);
+ }
+
+ pub fn fold_at_level_6(
+ &mut self,
+ _: &actions::FoldAtLevel6,
+ window: &mut Window,
+ cx: &mut Context<Self>,
+ ) {
+ self.fold_at_level(&actions::FoldAtLevel(6), window, cx);
+ }
+
+ pub fn fold_at_level_7(
+ &mut self,
+ _: &actions::FoldAtLevel7,
+ window: &mut Window,
+ cx: &mut Context<Self>,
+ ) {
+ self.fold_at_level(&actions::FoldAtLevel(7), window, cx);
+ }
+
+ pub fn fold_at_level_8(
+ &mut self,
+ _: &actions::FoldAtLevel8,
+ window: &mut Window,
+ cx: &mut Context<Self>,
+ ) {
+ self.fold_at_level(&actions::FoldAtLevel(8), window, cx);
+ }
+
+ pub fn fold_at_level_9(
+ &mut self,
+ _: &actions::FoldAtLevel9,
+ window: &mut Window,
+ cx: &mut Context<Self>,
+ ) {
+ self.fold_at_level(&actions::FoldAtLevel(9), window, cx);
+ }
+
pub fn fold_all(&mut self, _: &actions::FoldAll, window: &mut Window, cx: &mut Context<Self>) {
if self.buffer.read(cx).is_singleton() {
let mut fold_ranges = Vec::new();
@@ -432,6 +432,15 @@ impl EditorElement {
register_action(editor, window, Editor::open_selected_filename);
register_action(editor, window, Editor::fold);
register_action(editor, window, Editor::fold_at_level);
+ register_action(editor, window, Editor::fold_at_level_1);
+ register_action(editor, window, Editor::fold_at_level_2);
+ register_action(editor, window, Editor::fold_at_level_3);
+ register_action(editor, window, Editor::fold_at_level_4);
+ register_action(editor, window, Editor::fold_at_level_5);
+ register_action(editor, window, Editor::fold_at_level_6);
+ register_action(editor, window, Editor::fold_at_level_7);
+ register_action(editor, window, Editor::fold_at_level_8);
+ register_action(editor, window, Editor::fold_at_level_9);
register_action(editor, window, Editor::fold_all);
register_action(editor, window, Editor::fold_function_bodies);
register_action(editor, window, Editor::fold_recursive);
@@ -156,6 +156,16 @@ static TRANSFORM_ARRAY: LazyLock<HashMap<(&str, &str), &str>> = LazyLock::new(||
(("vim::ResizePane", "Narrow"), "vim::ResizePaneLeft"),
(("vim::ResizePane", "Shorten"), "vim::ResizePaneDown"),
(("vim::ResizePane", "Lengthen"), "vim::ResizePaneUp"),
+ // fold at level
+ (("editor::FoldAtLevel", "1"), "editor::FoldAtLevel1"),
+ (("editor::FoldAtLevel", "2"), "editor::FoldAtLevel2"),
+ (("editor::FoldAtLevel", "3"), "editor::FoldAtLevel3"),
+ (("editor::FoldAtLevel", "4"), "editor::FoldAtLevel4"),
+ (("editor::FoldAtLevel", "5"), "editor::FoldAtLevel5"),
+ (("editor::FoldAtLevel", "6"), "editor::FoldAtLevel6"),
+ (("editor::FoldAtLevel", "7"), "editor::FoldAtLevel7"),
+ (("editor::FoldAtLevel", "8"), "editor::FoldAtLevel8"),
+ (("editor::FoldAtLevel", "9"), "editor::FoldAtLevel9"),
])
});