format: Re-implement support for formatting with code actions that contain commands (#28392)

Closes #27692
Closes #27935

Release Notes:

- Fixed a regression where code-actions used when formatting on save
were rejected if they contained commands
This commit is contained in:
Ben Kunkle
2025-04-09 01:53:54 +00:00
committed by GitHub
parent 301fc7cd7b
commit e66a24edcf
5 changed files with 421 additions and 201 deletions
+12 -3
View File
@@ -130,6 +130,12 @@ pub struct Transaction {
pub start: clock::Global,
}
impl Transaction {
pub fn merge_in(&mut self, other: Transaction) {
self.edit_ids.extend(other.edit_ids);
}
}
impl HistoryEntry {
pub fn transaction_id(&self) -> TransactionId {
self.transaction.id
@@ -1423,8 +1429,12 @@ impl Buffer {
.collect()
}
pub fn forget_transaction(&mut self, transaction_id: TransactionId) {
self.history.forget(transaction_id);
pub fn forget_transaction(&mut self, transaction_id: TransactionId) -> Option<Transaction> {
self.history.forget(transaction_id)
}
pub fn get_transaction(&self, transaction_id: TransactionId) -> Option<&Transaction> {
self.history.transaction(transaction_id)
}
pub fn merge_transactions(&mut self, transaction: TransactionId, destination: TransactionId) {
@@ -1482,7 +1492,6 @@ impl Buffer {
pub fn push_transaction(&mut self, transaction: Transaction, now: Instant) {
self.history.push_transaction(transaction, now);
self.history.finalize_last_transaction();
}
pub fn edited_ranges_for_transaction_id<D>(