git: Use LHS/RHS terminology consistently for side-by-side diff (#47949)

We were using primary/secondary in some places which is just
unnecessarily confusing.

Release Notes:

- N/A

Co-authored-by: cameron <cameron.studdstreet@gmail.com>
Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
This commit is contained in:
authored and GitHub committed 2026-01-29 17:36:15 +00:00
1 parent 749d00fdb8
commit 9c82416812
4 files changed
+384 -423

No files matched your search

+2 -2
View File
@@ -1551,7 +1551,7 @@ impl TextThreadEditor {
project_diff
.editor()
.read(cx)
.primary_editor()
.rhs_editor()
.read(cx)
.buffer()
.clone()
@@ -1560,7 +1560,7 @@ impl TextThreadEditor {
// Extract all stored comments from all hunks
let all_comments: Vec<(DiffHunkKey, Vec<StoredReviewComment>)> =
project_diff.update(cx, |project_diff, cx| {
let editor = project_diff.editor().read(cx).primary_editor().clone();
let editor = project_diff.editor().read(cx).rhs_editor().clone();
editor.update(cx, |editor, cx| editor.take_all_review_comments(cx))
});
+331 -362
View File
File diff suppressed because it is too large. Load diff
+3 -3
View File
@@ -148,12 +148,12 @@ impl RenderOnce for SplitEditorView {
let splittable_editor = self.splittable_editor.read(cx);
assert!(
splittable_editor.secondary_editor().is_some(),
splittable_editor.lhs_editor().is_some(),
"`SplitEditorView` requires `SplittableEditor` to be in split mode"
);
let lhs_editor = splittable_editor.secondary_editor().unwrap().clone();
let rhs_editor = splittable_editor.primary_editor().clone();
let lhs_editor = splittable_editor.lhs_editor().unwrap().clone();
let rhs_editor = splittable_editor.rhs_editor().clone();
let mut lhs = EditorElement::new(&lhs_editor, self.style.clone());
let mut rhs = EditorElement::new(&rhs_editor, self.style.clone());
+48 -56
View File
@@ -218,7 +218,7 @@ impl ProjectDiff {
pub fn autoscroll(&self, cx: &mut Context<Self>) {
self.editor.update(cx, |editor, cx| {
editor.primary_editor().update(cx, |editor, cx| {
editor.rhs_editor().update(cx, |editor, cx| {
editor.request_autoscroll(Autoscroll::fit(), cx);
})
})
@@ -288,35 +288,33 @@ impl ProjectDiff {
window,
cx,
);
diff_display_editor
.primary_editor()
.update(cx, |editor, cx| {
editor.disable_diagnostics(cx);
editor.set_show_diff_review_button(true, cx);
diff_display_editor.rhs_editor().update(cx, |editor, cx| {
editor.disable_diagnostics(cx);
editor.set_show_diff_review_button(true, cx);
match branch_diff.read(cx).diff_base() {
DiffBase::Head => {
editor.register_addon(GitPanelAddon {
workspace: workspace.downgrade(),
});
}
DiffBase::Merge { .. } => {
editor.register_addon(BranchDiffAddon {
branch_diff: branch_diff.clone(),
});
editor.start_temporary_diff_override();
editor.set_render_diff_hunk_controls(
Arc::new(|_, _, _, _, _, _, _, _| gpui::Empty.into_any_element()),
cx,
);
}
match branch_diff.read(cx).diff_base() {
DiffBase::Head => {
editor.register_addon(GitPanelAddon {
workspace: workspace.downgrade(),
});
}
});
DiffBase::Merge { .. } => {
editor.register_addon(BranchDiffAddon {
branch_diff: branch_diff.clone(),
});
editor.start_temporary_diff_override();
editor.set_render_diff_hunk_controls(
Arc::new(|_, _, _, _, _, _, _, _| gpui::Empty.into_any_element()),
cx,
);
}
}
});
diff_display_editor
});
let editor_subscription = cx.subscribe_in(&editor, window, Self::handle_editor_event);
let primary_editor = editor.read(cx).primary_editor().clone();
let primary_editor = editor.read(cx).rhs_editor().clone();
let review_comment_subscription =
cx.subscribe(&primary_editor, |this, _editor, event: &EditorEvent, cx| {
if let EditorEvent::ReviewCommentsChanged { total_count } = event {
@@ -443,7 +441,7 @@ impl ProjectDiff {
fn move_to_beginning(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.editor.update(cx, |editor, cx| {
editor.primary_editor().update(cx, |editor, cx| {
editor.rhs_editor().update(cx, |editor, cx| {
editor.move_to_beginning(&Default::default(), window, cx);
});
});
@@ -452,7 +450,7 @@ impl ProjectDiff {
fn move_to_path(&mut self, path_key: PathKey, window: &mut Window, cx: &mut Context<Self>) {
if let Some(position) = self.multibuffer.read(cx).location_for_path(&path_key, cx) {
self.editor.update(cx, |editor, cx| {
editor.primary_editor().update(cx, |editor, cx| {
editor.rhs_editor().update(cx, |editor, cx| {
editor.change_selections(
SelectionEffects::scroll(Autoscroll::focused()),
window,
@@ -480,7 +478,7 @@ impl ProjectDiff {
fn button_states(&self, cx: &App) -> ButtonStates {
let is_split = self.editor.read(cx).is_split();
let editor = self.editor.read(cx).primary_editor().read(cx);
let editor = self.editor.read(cx).rhs_editor().read(cx);
let snapshot = self.multibuffer.read(cx).snapshot(cx);
let prev_next = snapshot.diff_hunks().nth(1).is_some();
let mut selection = true;
@@ -494,7 +492,7 @@ impl ProjectDiff {
if let Some((excerpt_id, _, range)) = self
.editor
.read(cx)
.primary_editor()
.rhs_editor()
.read(cx)
.active_excerpt(cx)
{
@@ -603,7 +601,7 @@ impl ProjectDiff {
let conflict_addon = self
.editor
.read(cx)
.primary_editor()
.rhs_editor()
.read(cx)
.addon::<ConflictAddon>()
.expect("project diff editor should have a conflict addon");
@@ -635,12 +633,7 @@ impl ProjectDiff {
};
let (was_empty, is_excerpt_newly_added) = self.editor.update(cx, |editor, cx| {
let was_empty = editor
.primary_editor()
.read(cx)
.buffer()
.read(cx)
.is_empty();
let was_empty = editor.rhs_editor().read(cx).buffer().read(cx).is_empty();
let (_, is_newly_added) = editor.set_excerpts_for_path(
path_key.clone(),
buffer,
@@ -653,7 +646,7 @@ impl ProjectDiff {
});
self.editor.update(cx, |editor, cx| {
editor.primary_editor().update(cx, |editor, cx| {
editor.rhs_editor().update(cx, |editor, cx| {
if was_empty {
editor.change_selections(
SelectionEffects::no_scroll(),
@@ -837,7 +830,7 @@ impl Item for ProjectDiff {
fn deactivated(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.editor.update(cx, |editor, cx| {
editor.primary_editor().update(cx, |primary_editor, cx| {
editor.rhs_editor().update(cx, |primary_editor, cx| {
primary_editor.deactivated(window, cx);
})
});
@@ -850,7 +843,7 @@ impl Item for ProjectDiff {
cx: &mut Context<Self>,
) -> bool {
self.editor.update(cx, |editor, cx| {
editor.primary_editor().update(cx, |primary_editor, cx| {
editor.rhs_editor().update(cx, |primary_editor, cx| {
primary_editor.navigate(data, window, cx)
})
})
@@ -883,7 +876,7 @@ impl Item for ProjectDiff {
fn as_searchable(&self, _: &Entity<Self>, cx: &App) -> Option<Box<dyn SearchableItemHandle>> {
// TODO(split-diff) SplitEditor should be searchable
Some(Box::new(self.editor.read(cx).primary_editor().clone()))
Some(Box::new(self.editor.read(cx).rhs_editor().clone()))
}
fn for_each_project_item(
@@ -893,7 +886,7 @@ impl Item for ProjectDiff {
) {
self.editor
.read(cx)
.primary_editor()
.rhs_editor()
.read(cx)
.for_each_project_item(cx, f)
}
@@ -905,7 +898,7 @@ impl Item for ProjectDiff {
cx: &mut Context<Self>,
) {
self.editor.update(cx, |editor, cx| {
editor.primary_editor().update(cx, |primary_editor, _| {
editor.rhs_editor().update(cx, |primary_editor, _| {
primary_editor.set_nav_history(Some(nav_history));
})
});
@@ -952,7 +945,7 @@ impl Item for ProjectDiff {
cx: &mut Context<Self>,
) -> Task<Result<()>> {
self.editor.update(cx, |editor, cx| {
editor.primary_editor().update(cx, |primary_editor, cx| {
editor.rhs_editor().update(cx, |primary_editor, cx| {
primary_editor.save(options, project, window, cx)
})
})
@@ -975,7 +968,7 @@ impl Item for ProjectDiff {
cx: &mut Context<Self>,
) -> Task<Result<()>> {
self.editor.update(cx, |editor, cx| {
editor.primary_editor().update(cx, |primary_editor, cx| {
editor.rhs_editor().update(cx, |primary_editor, cx| {
primary_editor.reload(project, window, cx)
})
})
@@ -990,7 +983,7 @@ impl Item for ProjectDiff {
if type_id == TypeId::of::<Self>() {
Some(self_handle.clone().into())
} else if type_id == TypeId::of::<Editor>() {
Some(self.editor.read(cx).primary_editor().clone().into())
Some(self.editor.read(cx).rhs_editor().clone().into())
} else {
None
}
@@ -1911,7 +1904,7 @@ mod tests {
});
cx.run_until_parked();
let editor = diff.read_with(cx, |diff, cx| diff.editor.read(cx).primary_editor().clone());
let editor = diff.read_with(cx, |diff, cx| diff.editor.read(cx).rhs_editor().clone());
assert_state_with_diff(
&editor,
cx,
@@ -1971,7 +1964,7 @@ mod tests {
window,
cx,
);
diff.editor.read(cx).primary_editor().clone()
diff.editor.read(cx).rhs_editor().clone()
});
assert_state_with_diff(
&editor,
@@ -1992,7 +1985,7 @@ mod tests {
window,
cx,
);
diff.editor.read(cx).primary_editor().clone()
diff.editor.read(cx).rhs_editor().clone()
});
assert_state_with_diff(
&editor,
@@ -2044,8 +2037,7 @@ mod tests {
});
cx.run_until_parked();
let diff_editor =
diff.read_with(cx, |diff, cx| diff.editor.read(cx).primary_editor().clone());
let diff_editor = diff.read_with(cx, |diff, cx| diff.editor.read(cx).rhs_editor().clone());
assert_state_with_diff(
&diff_editor,
@@ -2169,7 +2161,7 @@ mod tests {
workspace.active_item_as::<ProjectDiff>(cx).unwrap()
});
cx.focus(&item);
let editor = item.read_with(cx, |item, cx| item.editor.read(cx).primary_editor().clone());
let editor = item.read_with(cx, |item, cx| item.editor.read(cx).rhs_editor().clone());
let mut cx = EditorTestContext::for_editor_in(editor, cx).await;
@@ -2283,7 +2275,7 @@ mod tests {
workspace.active_item_as::<ProjectDiff>(cx).unwrap()
});
cx.focus(&item);
let editor = item.read_with(cx, |item, cx| item.editor.read(cx).primary_editor().clone());
let editor = item.read_with(cx, |item, cx| item.editor.read(cx).rhs_editor().clone());
let mut cx = EditorTestContext::for_editor_in(editor, cx).await;
@@ -2330,7 +2322,7 @@ mod tests {
cx.run_until_parked();
cx.update(|window, cx| {
let editor = diff.read(cx).editor.read(cx).primary_editor().clone();
let editor = diff.read(cx).editor.read(cx).rhs_editor().clone();
let excerpt_ids = editor.read(cx).buffer().read(cx).excerpt_ids();
assert_eq!(excerpt_ids.len(), 1);
let excerpt_id = excerpt_ids[0];
@@ -2347,7 +2339,7 @@ mod tests {
.read(cx)
.editor
.read(cx)
.primary_editor()
.rhs_editor()
.read(cx)
.addon::<ConflictAddon>()
.unwrap()
@@ -2432,7 +2424,7 @@ mod tests {
);
cx.run_until_parked();
let editor = diff.read_with(cx, |diff, cx| diff.editor.read(cx).primary_editor().clone());
let editor = diff.read_with(cx, |diff, cx| diff.editor.read(cx).rhs_editor().clone());
assert_state_with_diff(
&editor,
@@ -2543,7 +2535,7 @@ mod tests {
);
cx.run_until_parked();
let editor = diff.read_with(cx, |diff, cx| diff.editor.read(cx).primary_editor().clone());
let editor = diff.read_with(cx, |diff, cx| diff.editor.read(cx).rhs_editor().clone());
assert_state_with_diff(
&editor,
@@ -2637,7 +2629,7 @@ mod tests {
workspace.active_item_as::<ProjectDiff>(cx).unwrap()
});
cx.focus(&item);
let editor = item.read_with(cx, |item, cx| item.editor.read(cx).primary_editor().clone());
let editor = item.read_with(cx, |item, cx| item.editor.read(cx).rhs_editor().clone());
fs.set_head_and_index_for_repo(
Path::new(path!("/project/.git")),