Restore Pen tool undo/redo and fix incorrect triggering of undo when changing tools (#2193)

Fixes ghost anchors, and allows undo in pentool

Fixes https://discord.com/channels/731730685944922173/881073965047636018/1267365764231598186.
Fixes https://discord.com/channels/731730685944922173/881073965047636018/1327376421034922045.
Fixes #2152.

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
mTvare 2025-01-19 13:16:28 +05:30 committed by GitHub
parent 9a25555732
commit ad68b1e5c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 7 deletions

View File

@ -332,9 +332,8 @@ impl PenToolData {
}, },
}); });
} }
if close_subpath { responses.add(DocumentMessage::EndTransaction);
responses.add(DocumentMessage::EndTransaction); if !close_subpath {
} else {
self.add_point(LastPoint { self.add_point(LastPoint {
id: end, id: end,
pos: next_point, pos: next_point,
@ -764,7 +763,7 @@ impl Fsm for PenToolFsmState {
state state
} }
(PenToolFsmState::DraggingHandle | PenToolFsmState::PlacingAnchor, PenToolMessage::Abort | PenToolMessage::Confirm) => { (PenToolFsmState::DraggingHandle | PenToolFsmState::PlacingAnchor, PenToolMessage::Confirm) => {
responses.add(DocumentMessage::EndTransaction); responses.add(DocumentMessage::EndTransaction);
tool_data.handle_end = None; tool_data.handle_end = None;
tool_data.latest_points.clear(); tool_data.latest_points.clear();
@ -793,9 +792,8 @@ impl Fsm for PenToolFsmState {
} }
(_, PenToolMessage::Redo) => { (_, PenToolMessage::Redo) => {
tool_data.point_index = (tool_data.point_index + 1).min(tool_data.latest_points.len().saturating_sub(1)); tool_data.point_index = (tool_data.point_index + 1).min(tool_data.latest_points.len().saturating_sub(1));
tool_data tool_data.place_anchor(SnapData::new(document, input), transform, input.mouse.position, responses);
.place_anchor(SnapData::new(document, input), transform, input.mouse.position, responses) (tool_data.point_index == 0).then_some(PenToolFsmState::Ready).unwrap_or(PenToolFsmState::PlacingAnchor)
.unwrap_or(PenToolFsmState::PlacingAnchor)
} }
_ => self, _ => self,
} }