Fix chaining GRS commands so they work smoothly and don't add intermediate undo steps (#2297)

Fix GRS chaining behaviour and generalise Abort to have n≠1 undos

Fixes https://discord.com/channels/731730685944922173/881073965047636018/1328281947918696458
This commit is contained in:
mTvare
2025-03-06 13:16:19 +00:00
committed by GitHub
parent 8f7dd2021d
commit 0c1e96b9c6
3 changed files with 20 additions and 5 deletions
@@ -165,6 +165,9 @@ pub enum DocumentMessage {
EndTransaction,
CommitTransaction,
AbortTransaction,
RepeatedAbortTransaction {
undo_count: usize,
},
AddTransaction,
ToggleLayerExpansion {
id: NodeId,
@@ -1183,11 +1183,17 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
self.document_redo_history.clear();
}
DocumentMessage::AbortTransaction => {
responses.add(DocumentMessage::RepeatedAbortTransaction { undo_count: 1 });
}
DocumentMessage::RepeatedAbortTransaction { undo_count } => {
if self.network_interface.transaction_status() == TransactionStatus::Finished {
return;
}
self.undo(ipp, responses);
for _ in 0..undo_count {
self.undo(ipp, responses);
}
self.network_interface.finish_transaction();
responses.add(OverlaysMessage::Draw);
}