CollapseAllDiffHunks action for editor (#40668)

This PR adds a new action `editor::CollapseAllDiffHunks`
which will allow the user to choose any keybinding for hiding the
Expanded Diff Hunks.
This commit is contained in:
Josh Piasecki
2025-10-20 18:18:01 +00:00
committed by GitHub
parent 78bfda5045
commit 13fe9938c2
3 changed files with 14 additions and 0 deletions
+2
View File
@@ -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.
+11
View File
@@ -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,
+1
View File
@@ -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);