Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions crates/agent_ui/src/agent_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,17 @@ impl AgentDiffPane {
.map(|diff_hunk| diff_hunk.buffer_range.to_point(&snapshot))
.collect::<Vec<_>>();

let (was_empty, is_excerpt_newly_added) =
self.multibuffer.update(cx, |multibuffer, cx| {
let was_empty = multibuffer.is_empty();
let is_excerpt_newly_added = multibuffer.update_excerpts_for_path(
path_key.clone(),
buffer.clone(),
diff_hunk_ranges,
multibuffer_context_lines(cx),
cx,
);
multibuffer.add_diff(diff_handle.clone(), cx);
(was_empty, is_excerpt_newly_added)
});
let was_empty = self.multibuffer.read(cx).is_empty();
let is_excerpt_newly_added = self.editor.update(cx, |editor, cx| {
editor.update_excerpts_for_path(
path_key.clone(),
buffer.clone(),
diff_hunk_ranges,
multibuffer_context_lines(cx),
diff_handle.clone(),
cx,
)
});

let rhs_editor = self.editor.read(cx).rhs_editor().clone();
rhs_editor.update(cx, |editor, cx| {
Expand Down Expand Up @@ -216,9 +214,9 @@ impl AgentDiffPane {
});
}

self.multibuffer.update(cx, |multibuffer, cx| {
self.editor.update(cx, |editor, cx| {
for buffer_id in buffers_to_delete {
multibuffer.remove_excerpts_for_buffer(buffer_id, cx);
editor.remove_excerpts_for_buffer(buffer_id, cx);
}
});

Expand Down
12 changes: 12 additions & 0 deletions crates/editor/src/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,18 @@ impl SplittableEditor {
}
}
}

pub fn remove_excerpts_for_buffer(
&mut self,
buffer_id: BufferId,
cx: &mut Context<'_, SplittableEditor>,
) {
let snapshot = self.rhs_multibuffer.read(cx).snapshot(cx);
let Some(path) = snapshot.path_for_buffer(buffer_id) else {
return;
};
self.remove_excerpts_for_path(path.clone(), cx);
}
}

#[cfg(test)]
Expand Down
Loading