crosshare-org / crosshare

Crosshare is a free and ad-free community for crossword constructors and solvers
https://crosshare.org
GNU Affero General Public License v3.0
109 stars 27 forks source link

Explicitly define grid diff for undo/redo #494

Closed legnes closed 1 month ago

legnes commented 1 month ago

TL;DR: Fixes a bug in undo/redo that happens when you click a fill suggestion!


The builder doesn't explicitly keep track of grid state entry patterns (used by the autofill), but they are de facto updated/captured anywhere fromCells() is called, including in the undo stack. However, they are not captured when you click on a fill word. This means clicking on a fill word causes the undo stack to get out of sync with the grid state until the next time you enter a letter or do something else that calls fromCells().

Solution here is to explicitly define what on the grid state matters for undo/redo -- hopefully an allowlist kind of model will be safer (at the expense of a small amount of extra maintenance when adding new undo-able stuff to the grid state).

mdirolf commented 1 month ago

Thanks for the quick fix!