Struggling with history when appendTransactions in multiple plugins

I have three plugins:

  1. enterMark - When cursor enters a mark, replace it with a text in the appendTransaction using tr.replaceWith().
  2. decorateMark - Apply decorations on the text.
  3. exitMark - When cursor exits the text, replace it with a mark in appendTransaction using tr.replaceWith().

They work fine.

Things go haywire when I redo and undo in the process.

Demo: Glitch :・゚✧

Video demo: 2023-04-09-14-39-28(1)

Steps to reproduce

  1. Place cursor at the right edge of bolded ‘can’.
  2. Type ‘12’.
  3. Press left arrow 2 times to arrive at right boundary of ‘can’
  4. Press right arrow 1 time to exit ‘should’.
  5. Execute undo 1 time. And execute redo 1 time.
  6. Press left arrow 1 time to arrive at right boundary of ‘can’
  7. Execute undo 2 times in a row.

I do not have the bandwidth to debug other people’s extension code. If you can reduce this to a minimal bit of code that shows the library misbehaving, I’ll gladly take a look, of course.

1 Like