Remove replica_id from MultiBuffers (#18141)

This PR removes the `replica_id` field from the `MultiBuffer` struct.

We were only ever referencing this field to pass when constructing a
`MultiBuffer`, and never used it outside of that.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers
2024-09-20 10:48:27 -04:00
committed by GitHub
parent 5f1046b3cd
commit ab1d466c5f
16 changed files with 54 additions and 84 deletions
+4 -18
View File
@@ -2155,10 +2155,6 @@ impl Editor {
});
}
pub fn replica_id(&self, cx: &AppContext) -> ReplicaId {
self.buffer.read(cx).replica_id()
}
pub fn leader_peer_id(&self) -> Option<PeerId> {
self.leader_peer_id
}
@@ -4758,8 +4754,6 @@ impl Editor {
title: String,
mut cx: AsyncWindowContext,
) -> Result<()> {
let replica_id = this.update(&mut cx, |this, cx| this.replica_id(cx))?;
let mut entries = transaction.0.into_iter().collect::<Vec<_>>();
cx.update(|cx| {
entries.sort_unstable_by_key(|(buffer, _)| {
@@ -4802,8 +4796,7 @@ impl Editor {
let mut ranges_to_highlight = Vec::new();
let excerpt_buffer = cx.new_model(|cx| {
let mut multibuffer =
MultiBuffer::new(replica_id, Capability::ReadWrite).with_title(title);
let mut multibuffer = MultiBuffer::new(Capability::ReadWrite).with_title(title);
for (buffer_handle, transaction) in &entries {
let buffer = buffer_handle.read(cx);
ranges_to_highlight.extend(
@@ -9610,7 +9603,6 @@ impl Editor {
})
})
} else if !definitions.is_empty() {
let replica_id = self.replica_id(cx);
cx.spawn(|editor, mut cx| async move {
let (title, location_tasks, workspace) = editor
.update(&mut cx, |editor, cx| {
@@ -9663,9 +9655,7 @@ impl Editor {
};
let opened = workspace
.update(&mut cx, |workspace, cx| {
Self::open_locations_in_multibuffer(
workspace, locations, replica_id, title, split, cx,
)
Self::open_locations_in_multibuffer(workspace, locations, title, split, cx)
})
.ok();
@@ -9762,7 +9752,6 @@ impl Editor {
}
let (buffer, head) = multi_buffer.text_anchor_for_position(head, cx)?;
let replica_id = self.replica_id(cx);
let workspace = self.workspace()?;
let project = workspace.read(cx).project().clone();
let references = project.update(cx, |project, cx| project.references(&buffer, head, cx));
@@ -9803,9 +9792,7 @@ impl Editor {
)
})
.unwrap();
Self::open_locations_in_multibuffer(
workspace, locations, replica_id, title, false, cx,
);
Self::open_locations_in_multibuffer(workspace, locations, title, false, cx);
Navigated::Yes
})
}))
@@ -9815,7 +9802,6 @@ impl Editor {
pub fn open_locations_in_multibuffer(
workspace: &mut Workspace,
mut locations: Vec<Location>,
replica_id: ReplicaId,
title: String,
split: bool,
cx: &mut ViewContext<Workspace>,
@@ -9827,7 +9813,7 @@ impl Editor {
let capability = workspace.project().read(cx).capability();
let excerpt_buffer = cx.new_model(|cx| {
let mut multibuffer = MultiBuffer::new(replica_id, capability);
let mut multibuffer = MultiBuffer::new(capability);
while let Some(location) = locations.next() {
let buffer = location.buffer.read(cx);
let mut ranges_for_buffer = Vec::new();