agent: Register tracked buffers with language servers (#28610)
Release Notes: - agent: Start language servers when accessing files via tools Co-authored-by: Michael <michael@zed.dev>
This commit is contained in:
parent
5994ac5cec
commit
dafe994eef
1 changed files with 7 additions and 1 deletions
|
@ -4,7 +4,7 @@ use collections::BTreeMap;
|
||||||
use futures::{StreamExt, channel::mpsc};
|
use futures::{StreamExt, channel::mpsc};
|
||||||
use gpui::{App, AppContext, AsyncApp, Context, Entity, Subscription, Task, WeakEntity};
|
use gpui::{App, AppContext, AsyncApp, Context, Entity, Subscription, Task, WeakEntity};
|
||||||
use language::{Anchor, Buffer, BufferEvent, DiskState, Point};
|
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 std::{cmp, ops::Range, sync::Arc};
|
||||||
use text::{Edit, Patch, Rope};
|
use text::{Edit, Patch, Rope};
|
||||||
use util::RangeExt;
|
use util::RangeExt;
|
||||||
|
@ -49,6 +49,10 @@ impl ActionLog {
|
||||||
.tracked_buffers
|
.tracked_buffers
|
||||||
.entry(buffer.clone())
|
.entry(buffer.clone())
|
||||||
.or_insert_with(|| {
|
.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 text_snapshot = buffer.read(cx).text_snapshot();
|
||||||
let diff = cx.new(|cx| BufferDiff::new(&text_snapshot, cx));
|
let diff = cx.new(|cx| BufferDiff::new(&text_snapshot, cx));
|
||||||
let (diff_update_tx, diff_update_rx) = mpsc::unbounded();
|
let (diff_update_tx, diff_update_rx) = mpsc::unbounded();
|
||||||
|
@ -76,6 +80,7 @@ impl ActionLog {
|
||||||
version: buffer.read(cx).version(),
|
version: buffer.read(cx).version(),
|
||||||
diff,
|
diff,
|
||||||
diff_update: diff_update_tx,
|
diff_update: diff_update_tx,
|
||||||
|
_open_lsp_handle: open_lsp_handle,
|
||||||
_maintain_diff: cx.spawn({
|
_maintain_diff: cx.spawn({
|
||||||
let buffer = buffer.clone();
|
let buffer = buffer.clone();
|
||||||
async move |this, cx| {
|
async move |this, cx| {
|
||||||
|
@ -615,6 +620,7 @@ struct TrackedBuffer {
|
||||||
diff: Entity<BufferDiff>,
|
diff: Entity<BufferDiff>,
|
||||||
snapshot: text::BufferSnapshot,
|
snapshot: text::BufferSnapshot,
|
||||||
diff_update: mpsc::UnboundedSender<(ChangeAuthor, text::BufferSnapshot)>,
|
diff_update: mpsc::UnboundedSender<(ChangeAuthor, text::BufferSnapshot)>,
|
||||||
|
_open_lsp_handle: OpenLspBufferHandle,
|
||||||
_maintain_diff: Task<()>,
|
_maintain_diff: Task<()>,
|
||||||
_subscription: Subscription,
|
_subscription: Subscription,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue