Can I undo/redo cursor position only?

Hi, I am currently working on implementing functionalities as follow:

  1. user change cursor position and doc content, and user can click two buttons afterwards.
  2. By clicking button A, user could jump to last cursor position.
  3. By clicking button B, user could undo the doc changes(similar to ctrl+z in other editor)

it seems that the undoSelection() method cannot distinguish cursor position changes and doc content changes, i.e. I don’t know to revert cursor position changes seperately/independently.

Does codeMirror provide any possible solution/method about it? If not, will there be something that is helpful in the future?

Great thanks! : )

The built-in history implementation indeed cannot undo selection without also undoing the corresponding document changes. It would be possible for you to implement something like that in user code though.

1 Like

I get it. Thanks for your reply. : )