Allow to toggle git hunk diffs (#11080)
Part of https://github.com/zed-industries/zed/issues/4523 Added two new actions with the default keybindings ``` "cmd-'": "editor::ToggleHunkDiff", "cmd-\"": "editor::ExpandAllHunkDiffs", ``` that allow to browse git hunk diffs in Zed: https://github.com/zed-industries/zed/assets/2690773/9a8a7d10-ed06-4960-b4ee-fe28fc5c4768 The hunks are dynamic and alter on user folds and modifications, or toggle hidden, if the modifications were not adjacent to the expanded hunk. Release Notes: - Added `editor::ToggleHunkDiff` (`cmd-'`) and `editor::ExpandAllHunkDiffs` (`cmd-"`) actions to browse git hunk diffs in Zed
This commit is contained in:
parent
5831d80f51
commit
caa0d35b8b
24 changed files with 3115 additions and 249 deletions
|
@ -137,6 +137,7 @@ pub struct ScrollManager {
|
|||
hide_scrollbar_task: Option<Task<()>>,
|
||||
dragging_scrollbar: bool,
|
||||
visible_line_count: Option<f32>,
|
||||
forbid_vertical_scroll: bool,
|
||||
}
|
||||
|
||||
impl ScrollManager {
|
||||
|
@ -151,6 +152,7 @@ impl ScrollManager {
|
|||
dragging_scrollbar: false,
|
||||
last_autoscroll: None,
|
||||
visible_line_count: None,
|
||||
forbid_vertical_scroll: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,6 +187,9 @@ impl ScrollManager {
|
|||
workspace_id: Option<WorkspaceId>,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) {
|
||||
if self.forbid_vertical_scroll {
|
||||
return;
|
||||
}
|
||||
let (new_anchor, top_row) = if scroll_position.y <= 0. {
|
||||
(
|
||||
ScrollAnchor {
|
||||
|
@ -224,6 +229,9 @@ impl ScrollManager {
|
|||
workspace_id: Option<WorkspaceId>,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) {
|
||||
if self.forbid_vertical_scroll {
|
||||
return;
|
||||
}
|
||||
self.anchor = anchor;
|
||||
cx.emit(EditorEvent::ScrollPositionChanged { local, autoscroll });
|
||||
self.show_scrollbar(cx);
|
||||
|
@ -298,6 +306,14 @@ impl ScrollManager {
|
|||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_forbid_vertical_scroll(&mut self, forbid: bool) {
|
||||
self.forbid_vertical_scroll = forbid;
|
||||
}
|
||||
|
||||
pub fn forbid_vertical_scroll(&self) -> bool {
|
||||
self.forbid_vertical_scroll
|
||||
}
|
||||
}
|
||||
|
||||
impl Editor {
|
||||
|
@ -334,6 +350,9 @@ impl Editor {
|
|||
scroll_delta: gpui::Point<f32>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
if self.scroll_manager.forbid_vertical_scroll {
|
||||
return;
|
||||
}
|
||||
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||
let position = self.scroll_manager.anchor.scroll_position(&display_map) + scroll_delta;
|
||||
self.set_scroll_position_taking_display_map(position, true, false, display_map, cx);
|
||||
|
@ -344,6 +363,9 @@ impl Editor {
|
|||
scroll_position: gpui::Point<f32>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
if self.scroll_manager.forbid_vertical_scroll {
|
||||
return;
|
||||
}
|
||||
self.set_scroll_position_internal(scroll_position, true, false, cx);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue