Refine inline transformation UX (#12939)
https://github.com/zed-industries/zed/assets/482957/1790e32e-1f59-4831-8a4c-722cf441e7e9 Release Notes: - N/A --------- Co-authored-by: Richard <richard@zed.dev> Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
parent
9e3c5f3e12
commit
e1f4dfc068
20 changed files with 419 additions and 219 deletions
|
@ -356,6 +356,19 @@ impl History {
|
|||
}
|
||||
}
|
||||
|
||||
fn transaction(&self, transaction_id: TransactionId) -> Option<&Transaction> {
|
||||
let entry = self
|
||||
.undo_stack
|
||||
.iter()
|
||||
.rfind(|entry| entry.transaction.id == transaction_id)
|
||||
.or_else(|| {
|
||||
self.redo_stack
|
||||
.iter()
|
||||
.rfind(|entry| entry.transaction.id == transaction_id)
|
||||
})?;
|
||||
Some(&entry.transaction)
|
||||
}
|
||||
|
||||
fn transaction_mut(&mut self, transaction_id: TransactionId) -> Option<&mut Transaction> {
|
||||
let entry = self
|
||||
.undo_stack
|
||||
|
@ -1389,6 +1402,19 @@ impl Buffer {
|
|||
self.history.finalize_last_transaction();
|
||||
}
|
||||
|
||||
pub fn edited_ranges_for_transaction_id<D>(
|
||||
&self,
|
||||
transaction_id: TransactionId,
|
||||
) -> impl '_ + Iterator<Item = Range<D>>
|
||||
where
|
||||
D: TextDimension,
|
||||
{
|
||||
self.history
|
||||
.transaction(transaction_id)
|
||||
.into_iter()
|
||||
.flat_map(|transaction| self.edited_ranges_for_transaction(transaction))
|
||||
}
|
||||
|
||||
pub fn edited_ranges_for_transaction<'a, D>(
|
||||
&'a self,
|
||||
transaction: &'a Transaction,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue