Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

CollapseAllDiffHunks action for editor (#40668)

Josh Piasecki13fe9938c2b3
diff --git a/crates/editor/src/actions.rs b/crates/editor/src/actions.rs
index 530a547bb9d..810b84efcd4 100644
--- a/crates/editor/src/actions.rs
+++ b/crates/editor/src/actions.rs
@@ -458,6 +458,8 @@ actions!(
/// Expands all diff hunks in the editor.
#[action(deprecated_aliases = ["editor::ExpandAllHunkDiffs"])]
ExpandAllDiffHunks,
+ /// Collapses all diff hunks in the editor.
+ CollapseAllDiffHunks,
/// Expands macros recursively at cursor position.
ExpandMacroRecursively,
/// Finds all references to the symbol at cursor.
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 18fede90dd3..20ebff811d5 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -18792,6 +18792,17 @@ impl Editor {
});
}
+ pub fn collapse_all_diff_hunks(
+ &mut self,
+ _: &CollapseAllDiffHunks,
+ _window: &mut Window,
+ cx: &mut Context<Self>,
+ ) {
+ self.buffer.update(cx, |buffer, cx| {
+ buffer.collapse_diff_hunks(vec![Anchor::min()..Anchor::max()], cx)
+ });
+ }
+
pub fn toggle_selected_diff_hunks(
&mut self,
_: &ToggleSelectedDiffHunks,
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs
index 52e73bd01c1..b80953ad842 100644
--- a/crates/editor/src/element.rs
+++ b/crates/editor/src/element.rs
@@ -493,6 +493,7 @@ impl EditorElement {
register_action(editor, window, Editor::stage_and_next);
register_action(editor, window, Editor::unstage_and_next);
register_action(editor, window, Editor::expand_all_diff_hunks);
+ register_action(editor, window, Editor::collapse_all_diff_hunks);
register_action(editor, window, Editor::go_to_previous_change);
register_action(editor, window, Editor::go_to_next_change);