regular-express icon indicating copy to clipboard operation
regular-express copied to clipboard

Extra undo seems to delete redo history

Open nico-abram opened this issue 4 years ago • 1 comments

In the web demo: https://regular.express/

Typing 1 letter and then doing undo-redo works. But with an additional undo after we have nothing to undo, it seems to delete the redo stack, so undo-undo-redo does not redo the letter

This happened on firefox nightly, did not test other browsers but I imagine it reproduces

nico-abram avatar May 07 '21 02:05 nico-abram

I digged a bit, findings:

The redo stack seems to be getting cleared here: https://github.com/bvisness/regular-express/blob/837a58c4351d63711b0c31c627863c996bb090fd/src/undo.c#L81

I think:

  1. there is a weird undo at the bottom of the undo stack that changes CursorIndex (to 5 which seems out of bounds, I'm talking about the default Hello string in the demo)
  2. after that is undone, something sets it back to 4 before undo_commit
  3. we reach undo_commit() and the undo lib thinks there was an input to change the 5 to 4, so it clears the redo stack

nico-abram avatar May 07 '21 03:05 nico-abram