Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Ensure language is set on diffs from `ActionLog` and `AcpThread` (#46129)

Cole Miller75dde03134fa
diff --git a/crates/acp_thread/src/diff.rs b/crates/acp_thread/src/diff.rs
index fc0fff5318e..f65893a87d9 100644
--- a/crates/acp_thread/src/diff.rs
+++ b/crates/acp_thread/src/diff.rs
@@ -86,9 +86,16 @@ impl Diff {
pub fn new(buffer: Entity<Buffer>, cx: &mut Context<Self>) -> Self {
let buffer_text_snapshot = buffer.read(cx).text_snapshot();
+ let language = buffer.read(cx).language().cloned();
+ let language_registry = buffer.read(cx).language_registry();
let buffer_diff = cx.new(|cx| {
let mut diff = BufferDiff::new_unchanged(&buffer_text_snapshot, cx);
- let secondary_diff = cx.new(|cx| BufferDiff::new_unchanged(&buffer_text_snapshot, cx));
+ diff.language_changed(language.clone(), language_registry.clone(), cx);
+ let secondary_diff = cx.new(|cx| {
+ let mut diff = BufferDiff::new_unchanged(&buffer_text_snapshot, cx);
+ diff.language_changed(language, language_registry, cx);
+ diff
+ });
diff.set_secondary_diff(secondary_diff);
diff
});
diff --git a/crates/action_log/src/action_log.rs b/crates/action_log/src/action_log.rs
index c5a649d6671..801765bb886 100644
--- a/crates/action_log/src/action_log.rs
+++ b/crates/action_log/src/action_log.rs
@@ -79,7 +79,13 @@ impl ActionLog {
});
let text_snapshot = buffer.read(cx).text_snapshot();
- let diff = cx.new(|cx| BufferDiff::new(&text_snapshot, cx));
+ let language = buffer.read(cx).language().cloned();
+ let language_registry = buffer.read(cx).language_registry();
+ let diff = cx.new(|cx| {
+ let mut diff = BufferDiff::new(&text_snapshot, cx);
+ diff.language_changed(language, language_registry, cx);
+ diff
+ });
let (diff_update_tx, diff_update_rx) = mpsc::unbounded();
let diff_base;
let unreviewed_edits;