Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
git: Ensure the sides of the side-by-side diff use the same hunk controls (#48376)
Cole Miller52c963df1d5d
diff --git a/crates/editor/src/split.rs b/crates/editor/src/split.rsindex 14ca7e7f652..f4236a1ab15 100644--- a/crates/editor/src/split.rs+++ b/crates/editor/src/split.rs@@ -25,7 +25,8 @@ use crate::{use workspace::{ActivatePaneLeft, ActivatePaneRight, Item, Workspace};use crate::{- Autoscroll, DisplayMap, Editor, EditorEvent, ToggleCodeActions, ToggleSoftWrap,+ Autoscroll, DisplayMap, Editor, EditorEvent, RenderDiffHunkControlsFn, ToggleCodeActions,+ ToggleSoftWrap,actions::{DisableBreakpoint, EditLogBreakpoint, EnableBreakpoint, ToggleBreakpoint},display_map::Companion,};@@ -308,6 +309,22 @@ impl SplittableEditor {self.lhs.is_some()}+ pub fn set_render_diff_hunk_controls(+ &self,+ render_diff_hunk_controls: RenderDiffHunkControlsFn,+ cx: &mut Context<Self>,+ ) {+ self.rhs_editor.update(cx, |editor, cx| {+ editor.set_render_diff_hunk_controls(render_diff_hunk_controls.clone(), cx);+ });++ if let Some(lhs) = &self.lhs {+ lhs.editor.update(cx, |editor, cx| {+ editor.set_render_diff_hunk_controls(render_diff_hunk_controls.clone(), cx);+ });+ }+ }+pub fn last_selected_editor(&self) -> &Entity<Editor> {if let Some(lhs) = &self.lhs&& lhs.has_latest_selection@@ -395,6 +412,8 @@ impl SplittableEditor {multibuffer.set_all_diff_hunks_expanded(cx);multibuffer});++ let render_diff_hunk_controls = self.rhs_editor.read(cx).render_diff_hunk_controls.clone();let lhs_editor = cx.new(|cx| {let mut editor =Editor::for_multibuffer(lhs_multibuffer.clone(), Some(project.clone()), window, cx);@@ -406,6 +425,10 @@ impl SplittableEditor {editor});+ lhs_editor.update(cx, |editor, cx| {+ editor.set_render_diff_hunk_controls(render_diff_hunk_controls, cx);+ });+let subscriptions =vec![cx.subscribe(&lhs_editor,diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rsindex a1239ae37a8..cb9310d6ed4 100644--- a/crates/git_ui/src/project_diff.rs+++ b/crates/git_ui/src/project_diff.rs@@ -288,6 +288,13 @@ impl ProjectDiff {window,cx,);+ match branch_diff.read(cx).diff_base() {+ DiffBase::Head => {}+ DiffBase::Merge { .. } => diff_display_editor.set_render_diff_hunk_controls(+ Arc::new(|_, _, _, _, _, _, _, _| gpui::Empty.into_any_element()),+ cx,+ ),+ }diff_display_editor.rhs_editor().update(cx, |editor, cx| {editor.disable_diagnostics(cx);editor.set_show_diff_review_button(true, cx);@@ -303,10 +310,6 @@ impl ProjectDiff {branch_diff: branch_diff.clone(),});editor.start_temporary_diff_override();- editor.set_render_diff_hunk_controls(- Arc::new(|_, _, _, _, _, _, _, _| gpui::Empty.into_any_element()),- cx,- );}}});