Fix Select tool's broken undo (#1597)

Fix select tool undo
This commit is contained in:
zhiyuan 2024-02-06 06:40:27 +08:00 committed by Keavon Chambers
parent 7e5069f638
commit e1735ddf84
3 changed files with 12 additions and 4 deletions

View File

@ -809,7 +809,7 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
}
Undo => {
self.undo_in_progress = true;
responses.add(ToolMessage::PreUndo);
responses.add(DocumentMessage::DocumentHistoryBackward);
responses.add(OverlaysMessage::Draw);
responses.add(DocumentMessage::UndoFinished);

View File

@ -126,6 +126,7 @@ pub enum ToolMessage {
},
DeactivateTools,
InitTools,
PreUndo,
Redo,
RefreshToolOptions,
ResetColors,

View File

@ -177,6 +177,15 @@ impl MessageHandler<ToolMessage, (&DocumentMessageHandler, DocumentId, &InputPre
tool_data.active_tool_mut().process_message(ToolMessage::UpdateHints, responses, &mut data);
tool_data.active_tool_mut().process_message(ToolMessage::UpdateCursor, responses, &mut data);
}
ToolMessage::PreUndo => {
let tool_data = &mut self.tool_state.tool_data;
match tool_data.active_tool_type {
ToolType::Pen => {}
_ => {
responses.add(BroadcastEvent::ToolAbort);
}
}
}
ToolMessage::Redo => {
let tool_data = &mut self.tool_state.tool_data;
match tool_data.active_tool_type {
@ -236,9 +245,7 @@ impl MessageHandler<ToolMessage, (&DocumentMessageHandler, DocumentId, &InputPre
ToolType::Pen => {
responses.add(PenToolMessage::Undo);
}
_ => {
responses.add(BroadcastEvent::ToolAbort);
}
_ => {}
}
}