Skip to content

fix: #5596 confirm unsaved changes regardless of startup action - #5912

Merged
Jocs merged 2 commits into
developfrom
fix/5596-confirm-unsaved-on-exit
Oct 27, 2026
Merged

Jocs merged 2 commits into
developfrom
fix/5596-confirm-unsaved-on-exit

Conversation

@Jocs

@Jocs Jocs commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Closes #5596

Summary

With Auto Save disabled and the default restoreAll startup action, closing an edited document's tab prompts to save, but closing its window silently keeps the edits only in the recovery cache. This makes the same document behave differently depending on how it is closed and can leave users expecting changes to have been saved to the original file.

Always request Save / Don't Save / Cancel when closing a window containing unsaved documents, including untitled drafts and documents switched to reading mode. Startup recovery no longer suppresses the confirmation. Saving must succeed before closing; discarding removes the edits from the recovery snapshot; canceling retains the window and its edits. Untouched documents and empty drafts still close directly.

Update Electron fixture cleanup, including manually restarted instances in the keybindings suite, to exit without waiting for interactive save prompts. Cleanup also runs when renderer-error assertions fail. The multi-folder recovery test now explicitly waits for a snapshot and simulates an abrupt process termination; the new close-flow tests exercise the actual BrowserWindow.close() and app.quit() paths.

Type of change

  • Bug fix (non-breaking, fixes an issue)
  • New feature (non-breaking, adds functionality)
  • Breaking change (causes existing functionality to change)
  • Documentation update

Test plan

  • TDD: reproduced three failing unit cases and a failing Electron close-flow test before applying the fix.
  • Added 18 unit cases covering startup actions, existing files, untitled drafts, reading mode, pending editor changes, snapshot failure, and discard/save completion.
  • Added 9 Electron E2E cases covering Save / Don't Save / Cancel for existing files and untitled drafts, canceled Save As, failed saves, and quitting from source mode. Restart checks verify saved content and that discarded edits do not return.
  • All 1,469 desktop unit tests passed.
  • 38 selected Electron E2E tests passed, including the new close cases, crash recovery, source-mode flushing, tab management, and layout restoration.
  • Reproduced the Linux CI keybindings teardown timeout locally, then passed all 15 keybindings and unsaved-close E2E cases after fixing restarted-instance cleanup.
  • pnpm run build:unpack, pnpm run lint, and pnpm run typecheck passed. Lint reports existing warnings without errors.
  • Tested in the real application on macOS / Electron 45. Native Windows/Linux verification remains for CI and follow-up testing.

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Build artifacts for PR #5912:

Run: https://github.com/marktext/marktext/actions/runs/40521953983

Artifact Size Link
marktext-linux-x64 729.5 MB Download
marktext-windows-arm64 327.3 MB Download
marktext-macos-x64 332.4 MB Download
marktext-linux-arm64 571.8 MB Download
marktext-macos-arm64 320.8 MB Download
marktext-windows-x64 335.4 MB Download

@Jocs
Jocs merged commit e796d2b into develop Oct 27, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant