Skip to content

UNDO malfunction #1321

Closed
Closed

Description

@GitPlayB

Description

Most of the time I can not undo actions like I want to.

  • Can you reproduce the issue?

Steps to reproduce

  1. Input something
  2. Undo several steps with Ctrl+Z
  3. Sometimes work, sometimes fail for Ctrl+Z
  4. Never accomplish "undo" undo(Ctrl+Shift+Z)

Expected behavior:

undo actions normally

Actual behavior:

can not undo normally

Versions

  • Mark Text: 0.15.0
  • Operating system: Windows 10 16299.904

Activity

  1. stefnotch commented on Sep 7, 2019

    @stefnotch
    Contributor

    I also have this issue

  2. stefnotch commented on Sep 7, 2019

    @stefnotch
    Contributor

    @fxha Regarding the keyboard input, from my understanding, you are using something quite different, but wouldn't it be easiest to just listen for keydown events and use
    event.key for text input
    event.code for keyboard shortcuts

    document.onkeydown = (ev) => {
     console.log(ev);
    }
    
    // Example: Pressing on the physical K key on a Colemak keyboard results in
    // KeyboardEvent {isTrusted: true, key: "e", code: "KeyK",.... }
    // which is perfect, because K is mapped to an E on the Colemak keyboard
  3. Ir1d commented on Sep 12, 2019

    @Ir1d

    I can reproduce

  4. fxha commented on Sep 12, 2019

    @fxha
    Contributor

    @stefnotch I guess this is not a shortcut problem instead a limit due memory usage that @Jocs implemented. All shorcuts should be mapped correctly because they are read from the system in the main process where we have no access to document. The undo/redo history is limited until we refactor our core and data structure. This may happen if you press multiple times Ctlr+Z and Ctrl+Shift+Z may not work after it or is limited to 1 or 2 redos.

  5. nh2 commented on Nov 14, 2019

    @nh2

    Even a single undo/redo does not work correctly on 0.16-rc.

    If you type _a_ and press undo (Ctrl+Z), it disapears, but if you then hit redo (Ctrl+Shift+Z), it does not reappear.

  6. hrvojegolcic commented on Nov 14, 2019

    @hrvojegolcic

    I can also reproduce in both 0.15 and 0.16. there is definitely a malfunction.

    1. Create a new paragraph
    2. Write 2 separate words
    3. Delete the first word (the second word remains)
    4. Press Ctrl+Z. Instead of reverting the deleted first word, the entire paragraph was removed (maybe this was an undo way too far into the history?)
    5. Pressing Ctrl+shift+Z now reverts the line but only to the state with a second word. There is no way to undo the delition of the first word. Toggling undo/redo only removes or reverts the line in the wrong state - the state after deletion of the first word instead of the state before deletion of the first word
  7. added
    🐛 bug
    on Nov 17, 2019
  8. Jocs commented on Nov 17, 2019

    @Jocs
    Member

    @nh2 @hrvojegolcic Thanks for you feedback, we'll optimize undo/redo in version 0.17.0.

  9. hamiltont commented on Jan 22, 2020

    @hamiltont

    Similar issues on macOS 10.14. Undo repeatedly does not behave in a sane manner (e.g. removes an entire paragraph instead of the one word I just typed), and I can't seem to get any redo functionality to work. Side note - love this editor, really excited to see it getting better over time!

  10. snowc0de commented on Aug 18, 2020

    @snowc0de

    i have a similar issue where when I press CTRL + Z It removes way too much text than expected. Instead of removing ~1 word, it removes the whole line, or a whole paragraph.

  11. KingMob commented on Oct 1, 2020

    @KingMob

    Has this reappeared? I'm having the same problem.

  12. stefandesu commented on Dec 10, 2020

    @stefandesu

    I'm using the most current version of Mark Text and the fact that 1. undo doesn't work as expected (almost always deletes things that I didn't intend to delete) and 2. redo doesn't work at all (#2399), make this app unusable. Within the few hours I've been using it, I've lost multiple pieces of text because of this. Nothing important, but still frustrating.

  13. phene commented on Dec 10, 2020

    @phene

    This is one of the bugs that lead to me and my colleague abandoning marktext in favor of Joplin.

  14. Jocs commented on Jun 26, 2026

    @Jocs
    Member

    Thank you for this report and to everyone who commented. This issue was caused by fundamental limitations in the old ContentState editor engine (acknowledged in the comments at the time). The editor engine has since been completely rewritten. The new engine uses an operation-transform (OT) based history system that computes lossless inverse operations for each edit, maintains a proper redo stack, and groups undo entries at word boundaries — so both undo granularity and redo are now correct. If you encounter any undo/redo problem in a recent build, please open a new issue with steps to reproduce against the current version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions