Commit a199655
authored
fix(editor): preserve pending diff when bailToMark target doesn't exist (tldraw#8260)
`bailToMark()` (and `_undo` with `toMark`) would silently discard the
pending diff when the target mark didn't exist in the undo stack. The
pending diff was cleared at the start of `_undo` but never restored on
early return, causing accumulated changes to be lost. Now the pending
diff is restored if the mark is not found.
Extracted from tldraw#8243.
### Change type
- [x] `bugfix`
### Test plan
1. Call `bailToMark` with a non-existent mark ID after making changes
2. Verify the pending changes are preserved (not silently discarded)
3. Verify a subsequent `bailToMark` with a valid mark still works
correctly
- [x] Unit tests
### Release notes
- Fix a bug where calling `bailToMark` with a non-existent mark ID could
silently discard pending history changes.
### Code changes
| Section | LOC change |
| --------- | ---------- |
| Core code | +7 / -2 |
| Tests | +16 / -0 |1 parent 32c4832 commit a199655
2 files changed
Lines changed: 23 additions & 2 deletions
File tree
- packages/editor/src/lib/editor/managers/HistoryManager
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
736 | 736 | | |
737 | 737 | | |
738 | 738 | | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
739 | 755 | | |
740 | 756 | | |
741 | 757 | | |
| |||
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
176 | | - | |
| 175 | + | |
| 176 | + | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
341 | 346 | | |
342 | 347 | | |
343 | 348 | | |
| |||
0 commit comments