assistant edit tool: Use buffer search and replace in background (#26679)

Instead of getting the whole text from the buffer, replacing with
`String::replace`, and getting a whole diff, we'll now use `SearchQuery`
to get a range, diff only that range, and apply it (all in the
background).

When we match zero strings, we'll record a "bad search", keep going and
report it to the model at the end.

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
This commit is contained in:
Agus Zubiaga 2025-03-13 12:25:49 -03:00 committed by GitHub
parent 6767e98e00
commit 8ec0309645
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 219 additions and 111 deletions

View file

@ -526,8 +526,8 @@ impl DerefMut for ChunkRendererContext<'_, '_> {
/// A set of edits to a given version of a buffer, computed asynchronously.
#[derive(Debug)]
pub struct Diff {
pub(crate) base_version: clock::Global,
line_ending: LineEnding,
pub base_version: clock::Global,
pub line_ending: LineEnding,
pub edits: Vec<(Range<usize>, Arc<str>)>,
}