From dafe994eef0ef1e31e2ec44b3c34878c0ac63cf0 Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Fri, 11 Apr 2025 16:27:24 -0600 Subject: [PATCH] agent: Register tracked buffers with language servers (#28610) Release Notes: - agent: Start language servers when accessing files via tools Co-authored-by: Michael --- crates/assistant_tool/src/action_log.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/assistant_tool/src/action_log.rs b/crates/assistant_tool/src/action_log.rs index 1c0911c189..fa305a512e 100644 --- a/crates/assistant_tool/src/action_log.rs +++ b/crates/assistant_tool/src/action_log.rs @@ -4,7 +4,7 @@ use collections::BTreeMap; use futures::{StreamExt, channel::mpsc}; use gpui::{App, AppContext, AsyncApp, Context, Entity, Subscription, Task, WeakEntity}; use language::{Anchor, Buffer, BufferEvent, DiskState, Point}; -use project::{Project, ProjectItem}; +use project::{Project, ProjectItem, lsp_store::OpenLspBufferHandle}; use std::{cmp, ops::Range, sync::Arc}; use text::{Edit, Patch, Rope}; use util::RangeExt; @@ -49,6 +49,10 @@ impl ActionLog { .tracked_buffers .entry(buffer.clone()) .or_insert_with(|| { + let open_lsp_handle = self.project.update(cx, |project, cx| { + project.register_buffer_with_language_servers(&buffer, cx) + }); + let text_snapshot = buffer.read(cx).text_snapshot(); let diff = cx.new(|cx| BufferDiff::new(&text_snapshot, cx)); let (diff_update_tx, diff_update_rx) = mpsc::unbounded(); @@ -76,6 +80,7 @@ impl ActionLog { version: buffer.read(cx).version(), diff, diff_update: diff_update_tx, + _open_lsp_handle: open_lsp_handle, _maintain_diff: cx.spawn({ let buffer = buffer.clone(); async move |this, cx| { @@ -615,6 +620,7 @@ struct TrackedBuffer { diff: Entity, snapshot: text::BufferSnapshot, diff_update: mpsc::UnboundedSender<(ChangeAuthor, text::BufferSnapshot)>, + _open_lsp_handle: OpenLspBufferHandle, _maintain_diff: Task<()>, _subscription: Subscription, }