Closed andy0130tw closed 2 months ago
This patch should help: https://github.com/codemirror/website/commit/8b30aec3ce78fb62de4021917fcc67d0affbb58c
Thank you again for your help. The patch you applied resolved the issue I initially reported, but I have encountered another case where the inverted effects are still failing. This time, the issue arises when I use delete
(fn-delete
on Mac) to erase multiple characters before the mark boundary, and then undo the changes in one go. The highlight after the first character is also lost after the undo.
This is reproducible in the example:
https://github.com/user-attachments/assets/69f1ead8-32cf-4cf5-bf3e-9009e30ba352
I replicated the example in a sandbox, looked into each transaction the editor has undergone. I noticed that, while the callback in invertedEffects.of
computed the effects needed for inverting the corresponding transaction, the undo manager concatenated multiple effects which should be mapped as if each were applied at the document it was attached to to ensure a correct outcome.
Very good point. That was an actual bug in the history implementation. Attached patch should help with this.
Describe the issue
I found a potential bug in the example demonstrating the use of
invertedEffects
from@codemirror/commands
. I can reproduce by the following sequence.Demo:
https://github.com/user-attachments/assets/e1141966-9786-42bd-9700-4f59f53cb9a3
Apologize that I have not spent time locating the bug. I will update this issue if I gain more insight on this.
Browser and platform
N/A
Reproduction link
https://codemirror.net/examples/inverted-effect/