Start tracking edits performed by the agent (#27064)

Release Notes:

- N/A

---------

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
Co-authored-by: Agus Zubiaga <hi@aguz.me>
This commit is contained in:
Antonio Scandurra 2025-03-19 14:07:25 +01:00 committed by GitHub
parent 23686aa394
commit ac5dafc6b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 1423 additions and 344 deletions

View file

@ -1498,9 +1498,9 @@ impl Buffer {
.flat_map(|transaction| self.edited_ranges_for_transaction(transaction))
}
pub fn edited_ranges_for_transaction<'a, D>(
pub fn edited_ranges_for_edit_ids<'a, D>(
&'a self,
transaction: &'a Transaction,
edit_ids: impl IntoIterator<Item = &'a clock::Lamport>,
) -> impl 'a + Iterator<Item = Range<D>>
where
D: TextDimension,
@ -1508,7 +1508,7 @@ impl Buffer {
// get fragment ranges
let mut cursor = self.fragments.cursor::<(Option<&Locator>, usize)>(&None);
let offset_ranges = self
.fragment_ids_for_edits(transaction.edit_ids.iter())
.fragment_ids_for_edits(edit_ids.into_iter())
.into_iter()
.filter_map(move |fragment_id| {
cursor.seek_forward(&Some(fragment_id), Bias::Left, &None);
@ -1547,6 +1547,16 @@ impl Buffer {
})
}
pub fn edited_ranges_for_transaction<'a, D>(
&'a self,
transaction: &'a Transaction,
) -> impl 'a + Iterator<Item = Range<D>>
where
D: TextDimension,
{
self.edited_ranges_for_edit_ids(&transaction.edit_ids)
}
pub fn subscribe(&mut self) -> Subscription {
self.subscriptions.subscribe()
}