From 75dde03134fa8820676a060921963af04345a6c2 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Mon, 5 Jan 2026 20:29:30 -0500 Subject: [PATCH] Ensure language is set on diffs from `ActionLog` and `AcpThread` (#46129) Release Notes: - N/A --- crates/acp_thread/src/diff.rs | 9 ++++++++- crates/action_log/src/action_log.rs | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/acp_thread/src/diff.rs b/crates/acp_thread/src/diff.rs index fc0fff5318ebeb1880b675e2df1dd401e4af1047..f65893a87d963b2b87258b278ee4f63054e5f0a1 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, cx: &mut Context) -> 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 c5a649d6671eb86ba2291e18498f33bc12f19849..801765bb88646ca0083619557b02e5e1081f93e6 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;