Skip to content

[Bug] Unsaved changes are discarded without warning when closing an edited Markdown file #5596

Closed

Description

@lucielavickova-tesena

Description

Description

When I edit an existing Markdown file and then close the document or MarkText without saving it manually, the changes are discarded without any warning.

I would expect MarkText to detect that the document contains unsaved changes and show a confirmation dialog asking whether I want to save, discard, or cancel closing the document.

This is particularly risky because there is no indication that the edits will be lost.

Additional information

The issue is reproducible with ordinary Markdown files and does not seem to depend on any specific Markdown content.

From a user perspective, silently discarding edits is a data-loss risk. Even with Auto Save disabled, the application should warn before closing a modified document.

Related to #4455 that should have been fixed, but I noticed it today again.

Steps to Reproduce

  1. Open an existing .md file in MarkText. Auto Save: disabled.
  2. Make any change to the document.
  3. Do not save the file manually.
  4. Close the document or close MarkText.
  5. Open the file again.

Expected Behavior

MarkText should detect the unsaved changes and display a confirmation dialog, for example:

  • Save
  • Don't Save
  • Cancel

Actual Behavior

The document closes immediately without any warning and all changes are lost.

Screenshots / Logs

No response

Operating System

Windows

MarkText Version

v0.19.1

OS Version

Windows 11

Reproducibility

  • I can reliably reproduce this issue

Activity

  1. Anton-V-K commented on Sep 30, 2026

    @Anton-V-K

    The issue #4455 seems to be fixed for 0.20.0 (worth checking against the latest RC build).
    BTW the editor indicates the modified state of a document with a green dot next to the filename (in the window caption):

    Image

    So if the dot doesn't appear after the content modification, the editor may discard the changes on close.

  2. lucielavickova-tesena commented on Oct 1, 2026

    @lucielavickova-tesena
    Author

    @Anton-V-K When I tried to check for updates, the app said my version is up to date. The 0.20.0 is pre-release. So I guess I need to wait for the official release then...

    Image
  3. Angelo-Mascaro commented on Oct 4, 2026

    @Angelo-Mascaro

    On windows 11 I have 0.20.0 and the bug is still there: I close and I lose the modifications.

  4. Anton-V-K commented on Oct 5, 2026

    @Anton-V-K

    pre-0.20.0 versions could ignore certain changes in text formatting, thus leading to unsaved changes loss.
    I guess, a specific scenario is needed.
    I've quickly tested the recent version 0.20.0 (on Windows 11), and it is quite good in detecting changes, even with Undo-Redo.

  5. added
    🚧 needs triage
    on Oct 12, 2026
  6. artofit commented on Oct 13, 2026

    @artofit

    I confirm the bug in v0.21.2 and was about to report it.
    It's not windows specific, I have it on Linux.

    Additionnally, would consider to add in the title bar the number of minutes since last save.

    Thanks

  7. Jocs commented on Oct 16, 2026

    @Jocs
    Member

    Tested against current develop source, commit 99c6039 (0.22.0-dev), on macOS with a fresh user-data directory and Auto Save explicitly disabled. Built the app from source and exercised the real Electron main/renderer close flow using Playwright.

    Could not reproduce the reported silent loss of edits:

    • Visual editor: closing an edited existing Markdown tab requests Save / Don’t Save / Cancel.
    • Visual editor: closing the window with startup action set to blank requests the same confirmation.
    • Source mode: both tab close and window close request the same confirmation.
    • In all four cases, returning Cancel keeps the modified tab and its edits open; the file on disk remains unchanged.
    • With the default “restore all” startup action, window close intentionally skips the save prompt. Closing and restarting with the same user-data directory restores the unsaved edits and the modified indicator; the original file on disk remains unchanged.

    The four confirmation cases and the close/restart restoration case passed. This verification covers the current development version on macOS, not the older reported releases or a native Windows/Linux run.

    Closing as unable to reproduce on current develop. If this persists on a newer build, please reopen with the exact version, startup action, editing mode, whether you close a tab or the window, and a minimal sequence of edits (including whether the modified indicator appears).

  8. mpasquato commented on Oct 23, 2026

    @mpasquato

    Hi! I'm experiencing this bug too with a different version.

    OS: Windows 11
    Version: 0.23.0
    Bug details:
    When closing through the windows close button, unsaved changes are discarded without warning. It happens even though the file's tab shows the dot marking the file as "edited".
    Important note: when closing the file through the close button in the tab or by using the ctrl+W shortcut, the warning modal with the options "save/don't save/cancel" is shown correctly.

    @Jocs I wanted to reopen the issues but seems like I do not have the permissions (sorry, first time collaborating in github, so I hope I'm doing everything alright)

  9. reopened this on Oct 23, 2026
  10. Jocs commented on Oct 23, 2026

    @Jocs
    Member

    @mpasquato Could you describe your problem in more detail? Or are you able to reproduce the issue consistently?

  11. mpasquato commented on Oct 23, 2026

    @mpasquato

    @Jocs Yes, I can reproduce it. But I think I found the culprit as I've been testing out different preferences settings. I'll describe two different use cases step by step.

    Use case 1

    Settings, under "Startup Files/Folders" the option "Open blank page" is selected

    1. Run MarkText
    2. Open a file
    3. Edit the file
    4. Press on window's [X] button
    5. A modal is shown with the "save/don't save/cancel" buttons.

    Works as intended.

    Use case 2

    Settings, under "Startup Files/Folders" the option "Restore all opened files and folders" is selected.

    1. Run MarkText
    2. Open a file
    3. Edit the file
    4. Press on window's [X] button
    5. MarkText closes. No modal is shown.
    6. (optional) Open the same file with notepad: the edits are not saved.
    7. Run MarkText again
    8. The file is shown with the edits, but they are have not been saved to the file itself yet.

    I think the behaviour in the use case n. 2 is the one making things unclear.

    At least to me, when I close a file, I would expect it to trigger the modal, no matter the fact that next time I run MarkText that same file will be opened with the (unsaved) edits available. Maybe that's the same problem other users were experiencing and couldn't pinpoint.

  12. Tikitronics commented on Oct 27, 2026

    @Tikitronics

    Same behaviour here. Really frustrating, I lost data twice since I rely on a program asking me if I want to save on exit.

  13. added
    🐛 bug
    🐞 pri/critical
    and removed
    🚧 needs triage
    on Oct 27, 2026
  14. Jocs commented on Oct 27, 2026

    @Jocs
    Member

    Thank you @lucielavickova-tesena and everyone who reported this and shared reproduction details. In particular, @mpasquato's comparison of "Open blank page" versus "Restore all opened files and folders", and the distinction between closing a tab and closing the window, made the triggering condition clear.

    The window-close path was deliberately skipping the save confirmation when restoreAll was selected, even though the document was correctly marked as modified. Retaining edits in the recovery cache does not make it clear to users that the original file has not been saved.

    I've opened #5912 to make the behavior consistent: closing a window or quitting with unsaved changes will request Save / Don't Save / Cancel, regardless of the startup setting, including for untitled drafts. Saving must succeed before closing; choosing Don't Save removes those edits from the recovery snapshot; Cancel keeps the window and its edits open.

    The change was developed with failing regression tests first and verified in the real application on macOS / Electron 45. All 1,469 unit tests and 38 selected Electron E2E tests passed, including restart checks, canceled/failed saves, source-mode quitting, and crash recovery.

    Thanks again for the concrete steps and for following up across versions. They helped turn this into a reproducible, test-covered fix.

  15. added a commit that references this issue on Oct 27, 2026
    e796d2b
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions