Skip to content

Data lost when switching from source code to preview mode #3590

Closed

Description

@tcharlss

Description

From time to time I lose all my recent edits when switching from Source Code mode to Preview mode.

There's no way to retrieve the lost data with undo or redo.

File → Auto Save is on.

  • Can you reproduce the issue?

I don't know exactly what triggers that bug, but it happens regularly.

I think each time, the document had some table. And possibly the document was not yet saved, I seem to recall there was a blue dot next to the tab.

Steps to reproduce

  1. Activate File → Auto Save
  2. Start in Source Code mode, make some edits. Add a moderately complex table.
  3. Switch to Preview mode
  4. Contemplate the loss of all your recent edits.
  5. Cry

Versions

  • MarkText version: 0.17.1, flatpak version
  • Operating system: Ubuntu 22.10

Activity

  1. added
    🐛 bug
    🐞 pri/critical
    on May 13, 2026
  2. Jocs commented on Jun 20, 2026

    @Jocs
    Member

    Thank you for reporting this! The MarkText editor engine has been completely rewritten (the legacy muyajs engine replaced by a new TypeScript @muyajs/core engine), and the source-code↔WYSIWYG mode handoff has been redesigned from scratch. When you exit source-code mode, the new engine explicitly captures CodeMirror's full content via getValue() and applies it to the WYSIWYG engine as a single, fully-invertible undo boundary — so edits (including complex tables) are never lost in the transition, even if the document was unsaved. This is covered by automated e2e tests that verify content survives the round-trip. If you encounter data loss with the current build, please reopen with a repro on the latest version.

  3. tcharlss commented on Jun 20, 2026

    @tcharlss
    Author

    Thanks for the fix and the explanation, looking forward to try it out

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🐞 pri/critical🔭 area/editor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions