Remove replica_id
from MultiBuffer
s (#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:
parent
5f1046b3cd
commit
ab1d466c5f
16 changed files with 54 additions and 84 deletions
|
@ -2814,9 +2814,8 @@ impl ContextEditor {
|
|||
} else {
|
||||
// If there are multiple buffers or suggestion groups, create a multibuffer
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let replica_id = project.read(cx).replica_id();
|
||||
let mut multibuffer = MultiBuffer::new(replica_id, Capability::ReadWrite)
|
||||
.with_title(resolved_step.title.clone());
|
||||
let mut multibuffer =
|
||||
MultiBuffer::new(Capability::ReadWrite).with_title(resolved_step.title.clone());
|
||||
for (buffer, groups) in &resolved_step.suggestion_groups {
|
||||
let excerpt_ids = multibuffer.push_excerpts(
|
||||
buffer.clone(),
|
||||
|
|
|
@ -1145,7 +1145,7 @@ impl InlineAssistant {
|
|||
|
||||
let deleted_lines_editor = cx.new_view(|cx| {
|
||||
let multi_buffer = cx.new_model(|_| {
|
||||
MultiBuffer::without_headers(0, language::Capability::ReadOnly)
|
||||
MultiBuffer::without_headers(language::Capability::ReadOnly)
|
||||
});
|
||||
multi_buffer.update(cx, |multi_buffer, cx| {
|
||||
multi_buffer.push_excerpts(
|
||||
|
|
|
@ -289,7 +289,7 @@ async fn test_basic_following(
|
|||
.get_open_buffer(&(worktree_id, "2.txt").into(), cx)
|
||||
.unwrap()
|
||||
});
|
||||
let mut result = MultiBuffer::new(0, Capability::ReadWrite);
|
||||
let mut result = MultiBuffer::new(Capability::ReadWrite);
|
||||
result.push_excerpts(
|
||||
buffer_a1,
|
||||
[ExcerptRange {
|
||||
|
|
|
@ -767,7 +767,7 @@ mod tests {
|
|||
let buffer_1 = cx.new_model(|cx| Buffer::local("a = 1\nb = 2\n", cx));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::local("c = 3\nd = 4\n", cx));
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0, language::Capability::ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(language::Capability::ReadWrite);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[ExcerptRange {
|
||||
|
@ -1018,7 +1018,7 @@ mod tests {
|
|||
.unwrap();
|
||||
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0, language::Capability::ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(language::Capability::ReadWrite);
|
||||
multibuffer.push_excerpts(
|
||||
private_buffer.clone(),
|
||||
[ExcerptRange {
|
||||
|
|
|
@ -156,12 +156,7 @@ impl ProjectDiagnosticsEditor {
|
|||
cx.on_focus_out(&focus_handle, |this, _event, cx| this.focus_out(cx))
|
||||
.detach();
|
||||
|
||||
let excerpts = cx.new_model(|cx| {
|
||||
MultiBuffer::new(
|
||||
project_handle.read(cx).replica_id(),
|
||||
project_handle.read(cx).capability(),
|
||||
)
|
||||
});
|
||||
let excerpts = cx.new_model(|cx| MultiBuffer::new(project_handle.read(cx).capability()));
|
||||
let editor = cx.new_view(|cx| {
|
||||
let mut editor =
|
||||
Editor::for_multibuffer(excerpts.clone(), Some(project_handle.clone()), false, cx);
|
||||
|
|
|
@ -1671,7 +1671,7 @@ mod tests {
|
|||
|
||||
let mut excerpt_ids = Vec::new();
|
||||
let multi_buffer = cx.new_model(|cx| {
|
||||
let mut multi_buffer = MultiBuffer::new(0, Capability::ReadWrite);
|
||||
let mut multi_buffer = MultiBuffer::new(Capability::ReadWrite);
|
||||
excerpt_ids.extend(multi_buffer.push_excerpts(
|
||||
buffer1.clone(),
|
||||
[ExcerptRange {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -2822,7 +2822,7 @@ fn test_indent_outdent_with_excerpts(cx: &mut TestAppContext) {
|
|||
Buffer::local("const c: usize = 3;\n", cx).with_language(rust_language, cx)
|
||||
});
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0, ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(ReadWrite);
|
||||
multibuffer.push_excerpts(
|
||||
toml_buffer.clone(),
|
||||
[ExcerptRange {
|
||||
|
@ -6671,7 +6671,7 @@ async fn test_multibuffer_format_during_save(cx: &mut gpui::TestAppContext) {
|
|||
.unwrap();
|
||||
|
||||
let multi_buffer = cx.new_model(|cx| {
|
||||
let mut multi_buffer = MultiBuffer::new(0, ReadWrite);
|
||||
let mut multi_buffer = MultiBuffer::new(ReadWrite);
|
||||
multi_buffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[
|
||||
|
@ -8614,7 +8614,7 @@ fn test_editing_disjoint_excerpts(cx: &mut TestAppContext) {
|
|||
|
||||
let buffer = cx.new_model(|cx| Buffer::local(sample_text(3, 4, 'a'), cx));
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0, ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(ReadWrite);
|
||||
multibuffer.push_excerpts(
|
||||
buffer.clone(),
|
||||
[
|
||||
|
@ -8698,7 +8698,7 @@ fn test_editing_overlapping_excerpts(cx: &mut TestAppContext) {
|
|||
});
|
||||
let buffer = cx.new_model(|cx| Buffer::local(initial_text, cx));
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0, ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(ReadWrite);
|
||||
multibuffer.push_excerpts(buffer, excerpt_ranges, cx);
|
||||
multibuffer
|
||||
});
|
||||
|
@ -8757,7 +8757,7 @@ fn test_refresh_selections(cx: &mut TestAppContext) {
|
|||
let buffer = cx.new_model(|cx| Buffer::local(sample_text(3, 4, 'a'), cx));
|
||||
let mut excerpt1_id = None;
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0, ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(ReadWrite);
|
||||
excerpt1_id = multibuffer
|
||||
.push_excerpts(
|
||||
buffer.clone(),
|
||||
|
@ -8842,7 +8842,7 @@ fn test_refresh_selections_while_selecting_with_mouse(cx: &mut TestAppContext) {
|
|||
let buffer = cx.new_model(|cx| Buffer::local(sample_text(3, 4, 'a'), cx));
|
||||
let mut excerpt1_id = None;
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0, ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(ReadWrite);
|
||||
excerpt1_id = multibuffer
|
||||
.push_excerpts(
|
||||
buffer.clone(),
|
||||
|
@ -9230,7 +9230,7 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
|
|||
let cx = &mut VisualTestContext::from_window(*workspace.deref(), cx);
|
||||
|
||||
let leader = pane.update(cx, |_, cx| {
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(ReadWrite));
|
||||
cx.new_view(|cx| build_editor(multibuffer.clone(), cx))
|
||||
});
|
||||
|
||||
|
@ -10685,7 +10685,7 @@ async fn test_multibuffer_reverts(cx: &mut gpui::TestAppContext) {
|
|||
diff_every_buffer_row(&buffer_3, sample_text_3.clone(), cols, cx);
|
||||
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0, ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(ReadWrite);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[
|
||||
|
@ -10825,7 +10825,7 @@ async fn test_mutlibuffer_in_navigation_history(cx: &mut gpui::TestAppContext) {
|
|||
let buffer_3 = cx.new_model(|cx| Buffer::local(sample_text_3.clone(), cx));
|
||||
|
||||
let multi_buffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0, ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(ReadWrite);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[
|
||||
|
@ -11764,7 +11764,7 @@ async fn test_toggle_diff_expand_in_multi_buffer(cx: &mut gpui::TestAppContext)
|
|||
});
|
||||
|
||||
let multi_buffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0, ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(ReadWrite);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[
|
||||
|
|
|
@ -195,7 +195,7 @@ mod tests {
|
|||
cx.background_executor.run_until_parked();
|
||||
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0, ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(ReadWrite);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[
|
||||
|
|
|
@ -764,7 +764,7 @@ fn editor_with_deleted_text(
|
|||
let parent_editor = cx.view().downgrade();
|
||||
let editor = cx.new_view(|cx| {
|
||||
let multi_buffer =
|
||||
cx.new_model(|_| MultiBuffer::without_headers(0, language::Capability::ReadOnly));
|
||||
cx.new_model(|_| MultiBuffer::without_headers(language::Capability::ReadOnly));
|
||||
multi_buffer.update(cx, |multi_buffer, cx| {
|
||||
multi_buffer.push_excerpts(
|
||||
diff_base_buffer,
|
||||
|
|
|
@ -2607,7 +2607,7 @@ pub mod tests {
|
|||
.await
|
||||
.unwrap();
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0, Capability::ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(Capability::ReadWrite);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[
|
||||
|
@ -2957,7 +2957,7 @@ pub mod tests {
|
|||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
let (buffer_1_excerpts, buffer_2_excerpts) = multibuffer.update(cx, |multibuffer, cx| {
|
||||
let buffer_1_excerpts = multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
|
|
|
@ -68,7 +68,6 @@ impl FollowableItem for Editor {
|
|||
unreachable!()
|
||||
};
|
||||
|
||||
let replica_id = project.read(cx).replica_id();
|
||||
let buffer_ids = state
|
||||
.excerpts
|
||||
.iter()
|
||||
|
@ -92,7 +91,7 @@ impl FollowableItem for Editor {
|
|||
if state.singleton && buffers.len() == 1 {
|
||||
multibuffer = MultiBuffer::singleton(buffers.pop().unwrap(), cx)
|
||||
} else {
|
||||
multibuffer = MultiBuffer::new(replica_id, project.read(cx).capability());
|
||||
multibuffer = MultiBuffer::new(project.read(cx).capability());
|
||||
let mut excerpts = state.excerpts.into_iter().peekable();
|
||||
while let Some(excerpt) = excerpts.peek() {
|
||||
let Ok(buffer_id) = BufferId::new(excerpt.buffer_id) else {
|
||||
|
|
|
@ -928,7 +928,7 @@ mod tests {
|
|||
|
||||
let buffer = cx.new_model(|cx| Buffer::local("abc\ndefg\nhijkl\nmn", cx));
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0, Capability::ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(Capability::ReadWrite);
|
||||
multibuffer.push_excerpts(
|
||||
buffer.clone(),
|
||||
[
|
||||
|
|
|
@ -75,7 +75,7 @@ impl EditorTestContext {
|
|||
cx: &mut gpui::TestAppContext,
|
||||
excerpts: [&str; COUNT],
|
||||
) -> EditorTestContext {
|
||||
let mut multibuffer = MultiBuffer::new(0, language::Capability::ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(language::Capability::ReadWrite);
|
||||
let buffer = cx.new_model(|cx| {
|
||||
for excerpt in excerpts.into_iter() {
|
||||
let (text, ranges) = marked_text_ranges(excerpt, false);
|
||||
|
|
|
@ -67,7 +67,6 @@ pub struct MultiBuffer {
|
|||
subscriptions: Topic,
|
||||
/// If true, the multi-buffer only contains a single [`Buffer`] and a single [`Excerpt`]
|
||||
singleton: bool,
|
||||
replica_id: ReplicaId,
|
||||
history: History,
|
||||
title: Option<String>,
|
||||
capability: Capability,
|
||||
|
@ -350,7 +349,7 @@ impl std::ops::Deref for MultiBufferIndentGuide {
|
|||
}
|
||||
|
||||
impl MultiBuffer {
|
||||
pub fn new(replica_id: ReplicaId, capability: Capability) -> Self {
|
||||
pub fn new(capability: Capability) -> Self {
|
||||
Self {
|
||||
snapshot: RefCell::new(MultiBufferSnapshot {
|
||||
show_headers: true,
|
||||
|
@ -360,7 +359,6 @@ impl MultiBuffer {
|
|||
subscriptions: Topic::default(),
|
||||
singleton: false,
|
||||
capability,
|
||||
replica_id,
|
||||
title: None,
|
||||
history: History {
|
||||
next_transaction_id: clock::Lamport::default(),
|
||||
|
@ -372,14 +370,13 @@ impl MultiBuffer {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn without_headers(replica_id: ReplicaId, capability: Capability) -> Self {
|
||||
pub fn without_headers(capability: Capability) -> Self {
|
||||
Self {
|
||||
snapshot: Default::default(),
|
||||
buffers: Default::default(),
|
||||
subscriptions: Default::default(),
|
||||
singleton: false,
|
||||
capability,
|
||||
replica_id,
|
||||
history: History {
|
||||
next_transaction_id: Default::default(),
|
||||
undo_stack: Default::default(),
|
||||
|
@ -414,7 +411,6 @@ impl MultiBuffer {
|
|||
subscriptions: Default::default(),
|
||||
singleton: self.singleton,
|
||||
capability: self.capability,
|
||||
replica_id: self.replica_id,
|
||||
history: self.history.clone(),
|
||||
title: self.title.clone(),
|
||||
}
|
||||
|
@ -430,7 +426,7 @@ impl MultiBuffer {
|
|||
}
|
||||
|
||||
pub fn singleton(buffer: Model<Buffer>, cx: &mut ModelContext<Self>) -> Self {
|
||||
let mut this = Self::new(buffer.read(cx).replica_id(), buffer.read(cx).capability());
|
||||
let mut this = Self::new(buffer.read(cx).capability());
|
||||
this.singleton = true;
|
||||
this.push_excerpts(
|
||||
buffer,
|
||||
|
@ -444,10 +440,6 @@ impl MultiBuffer {
|
|||
this
|
||||
}
|
||||
|
||||
pub fn replica_id(&self) -> ReplicaId {
|
||||
self.replica_id
|
||||
}
|
||||
|
||||
/// Returns an up-to-date snapshot of the MultiBuffer.
|
||||
pub fn snapshot(&self, cx: &AppContext) -> MultiBufferSnapshot {
|
||||
self.sync(cx);
|
||||
|
@ -2011,7 +2003,7 @@ impl MultiBuffer {
|
|||
excerpts: [(&str, Vec<Range<Point>>); COUNT],
|
||||
cx: &mut gpui::AppContext,
|
||||
) -> Model<Self> {
|
||||
let multi = cx.new_model(|_| Self::new(0, Capability::ReadWrite));
|
||||
let multi = cx.new_model(|_| Self::new(Capability::ReadWrite));
|
||||
for (text, ranges) in excerpts {
|
||||
let buffer = cx.new_model(|cx| Buffer::local(text, cx));
|
||||
let excerpt_ranges = ranges.into_iter().map(|range| ExcerptRange {
|
||||
|
@ -2032,7 +2024,7 @@ impl MultiBuffer {
|
|||
|
||||
pub fn build_random(rng: &mut impl rand::Rng, cx: &mut gpui::AppContext) -> Model<Self> {
|
||||
cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0, Capability::ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(Capability::ReadWrite);
|
||||
let mutation_count = rng.gen_range(1..=5);
|
||||
multibuffer.randomly_edit_excerpts(rng, mutation_count, cx);
|
||||
multibuffer
|
||||
|
@ -5063,7 +5055,7 @@ mod tests {
|
|||
fn test_excerpt_boundaries_and_clipping(cx: &mut AppContext) {
|
||||
let buffer_1 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'a'), cx));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'g'), cx));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
|
||||
let events = Arc::new(RwLock::new(Vec::<Event>::new()));
|
||||
multibuffer.update(cx, |_, cx| {
|
||||
|
@ -5306,8 +5298,8 @@ mod tests {
|
|||
let buffer_1 = cx.new_model(|cx| Buffer::local(sample_text(10, 3, 'a'), cx));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::local(sample_text(10, 3, 'm'), cx));
|
||||
|
||||
let leader_multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let follower_multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let leader_multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
let follower_multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
let follower_edit_event_count = Arc::new(RwLock::new(0));
|
||||
|
||||
follower_multibuffer.update(cx, |_, cx| {
|
||||
|
@ -5410,7 +5402,7 @@ mod tests {
|
|||
#[gpui::test]
|
||||
fn test_expand_excerpts(cx: &mut AppContext) {
|
||||
let buffer = cx.new_model(|cx| Buffer::local(sample_text(20, 3, 'a'), cx));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.push_excerpts_with_context_lines(
|
||||
|
@ -5486,7 +5478,7 @@ mod tests {
|
|||
#[gpui::test]
|
||||
fn test_push_excerpts_with_context_lines(cx: &mut AppContext) {
|
||||
let buffer = cx.new_model(|cx| Buffer::local(sample_text(20, 3, 'a'), cx));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
let anchor_ranges = multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.push_excerpts_with_context_lines(
|
||||
buffer.clone(),
|
||||
|
@ -5539,7 +5531,7 @@ mod tests {
|
|||
#[gpui::test]
|
||||
async fn test_stream_excerpts_with_context_lines(cx: &mut TestAppContext) {
|
||||
let buffer = cx.new_model(|cx| Buffer::local(sample_text(20, 3, 'a'), cx));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
let anchor_ranges = multibuffer.update(cx, |multibuffer, cx| {
|
||||
let snapshot = buffer.read(cx);
|
||||
let ranges = vec![
|
||||
|
@ -5589,7 +5581,7 @@ mod tests {
|
|||
|
||||
#[gpui::test]
|
||||
fn test_empty_multibuffer(cx: &mut AppContext) {
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
|
||||
let snapshot = multibuffer.read(cx).snapshot(cx);
|
||||
assert_eq!(snapshot.text(), "");
|
||||
|
@ -5628,7 +5620,7 @@ mod tests {
|
|||
let buffer_1 = cx.new_model(|cx| Buffer::local("abcd", cx));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::local("efghi", cx));
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0, Capability::ReadWrite);
|
||||
let mut multibuffer = MultiBuffer::new(Capability::ReadWrite);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
[ExcerptRange {
|
||||
|
@ -5685,7 +5677,7 @@ mod tests {
|
|||
fn test_resolving_anchors_after_replacing_their_excerpts(cx: &mut AppContext) {
|
||||
let buffer_1 = cx.new_model(|cx| Buffer::local("abcd", cx));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::local("ABCDEFGHIJKLMNOP", cx));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
|
||||
// Create an insertion id in buffer 1 that doesn't exist in buffer 2.
|
||||
// Add an excerpt from buffer 1 that spans this new insertion.
|
||||
|
@ -5819,7 +5811,7 @@ mod tests {
|
|||
.unwrap_or(10);
|
||||
|
||||
let mut buffers: Vec<Model<Buffer>> = Vec::new();
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
let mut excerpt_ids = Vec::<ExcerptId>::new();
|
||||
let mut expected_excerpts = Vec::<(Model<Buffer>, Range<text::Anchor>)>::new();
|
||||
let mut anchors = Vec::new();
|
||||
|
@ -6283,7 +6275,7 @@ mod tests {
|
|||
|
||||
let buffer_1 = cx.new_model(|cx| Buffer::local("1234", cx));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::local("5678", cx));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
let group_interval = multibuffer.read(cx).history.group_interval;
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.push_excerpts(
|
||||
|
@ -6418,7 +6410,7 @@ mod tests {
|
|||
fn test_excerpts_in_ranges_no_ranges(cx: &mut AppContext) {
|
||||
let buffer_1 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'a'), cx));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'g'), cx));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
|
@ -6496,7 +6488,7 @@ mod tests {
|
|||
let buffer_1 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'a'), cx));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'g'), cx));
|
||||
let buffer_len = buffer_1.read(cx).len();
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
let mut expected_excerpt_id = ExcerptId(0);
|
||||
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
|
@ -6557,7 +6549,7 @@ mod tests {
|
|||
let buffer_1 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'a'), cx));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'g'), cx));
|
||||
let buffer_len = buffer_1.read(cx).len();
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
let mut excerpt_1_id = ExcerptId(0);
|
||||
let mut excerpt_2_id = ExcerptId(0);
|
||||
|
||||
|
@ -6623,7 +6615,7 @@ mod tests {
|
|||
let buffer_2 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'g'), cx));
|
||||
let buffer_3 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'r'), cx));
|
||||
let buffer_len = buffer_1.read(cx).len();
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
let mut excerpt_1_id = ExcerptId(0);
|
||||
let mut excerpt_2_id = ExcerptId(0);
|
||||
let mut excerpt_3_id = ExcerptId(0);
|
||||
|
@ -6698,7 +6690,7 @@ mod tests {
|
|||
let buffer_1 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'a'), cx));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'g'), cx));
|
||||
let buffer_len = buffer_1.read(cx).len();
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
let mut excerpt_1_id = ExcerptId(0);
|
||||
let mut excerpt_2_id = ExcerptId(0);
|
||||
|
||||
|
@ -6764,7 +6756,7 @@ mod tests {
|
|||
let buffer_1 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'a'), cx));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'g'), cx));
|
||||
let buffer_len = buffer_1.read(cx).len();
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
let mut excerpt_1_id = ExcerptId(0);
|
||||
let mut excerpt_2_id = ExcerptId(0);
|
||||
|
||||
|
@ -6829,7 +6821,7 @@ mod tests {
|
|||
fn test_split_ranges(cx: &mut AppContext) {
|
||||
let buffer_1 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'a'), cx));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'g'), cx));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
|
@ -6885,7 +6877,7 @@ mod tests {
|
|||
let buffer_1 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'a'), cx));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'g'), cx));
|
||||
let buffer_3 = cx.new_model(|cx| Buffer::local(sample_text(6, 6, 'm'), cx));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0, Capability::ReadWrite));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
|
|
|
@ -176,12 +176,11 @@ pub struct ProjectSearchBar {
|
|||
|
||||
impl ProjectSearch {
|
||||
pub fn new(project: Model<Project>, cx: &mut ModelContext<Self>) -> Self {
|
||||
let replica_id = project.read(cx).replica_id();
|
||||
let capability = project.read(cx).capability();
|
||||
|
||||
Self {
|
||||
project,
|
||||
excerpts: cx.new_model(|_| MultiBuffer::new(replica_id, capability)),
|
||||
excerpts: cx.new_model(|_| MultiBuffer::new(capability)),
|
||||
pending_search: Default::default(),
|
||||
match_ranges: Default::default(),
|
||||
active_query: None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue