Skip to content

Fix: Resolve false unsaved prompt when closing unmodified files - #4075

Closed
stevenchenUCD wants to merge 5 commits into
marktext:developfrom
stevenchenUCD:claude/scan-project-011CUx3rfp8ZPjuF8R7KMzJi
Closed

stevenchenUCD wants to merge 5 commits into
marktext:developfrom
stevenchenUCD:claude/scan-project-011CUx3rfp8ZPjuF8R7KMzJi

Conversation

@stevenchenUCD

Copy link
Copy Markdown

This commit fixes issue #1 where the editor would incorrectly prompt to save files upon closing, even when no local modifications were made.

Problem:

  • When a file was externally modified on disk, the code unconditionally set isSaved = false, causing the "unsaved changes" prompt even for unmodified files

Solution:

  • Distinguish between "file already saved" and "file has local changes" states
  • If file is saved: silently load external changes with info notification
  • If file has unsaved changes: prompt user whether to reload

Also added:

  • USAGE_GUIDE_CN.md: Chinese usage guide documenting that multi-window and PDF export features already exist in the application

Changes:

  • src/renderer/store/editor.js (lines 1169-1195): Fixed file change handling logic
  • USAGE_GUIDE_CN.md: New documentation file
Q A
Bug fix? yes/no
New feature? yes/no
Breaking changes? yes/no
Deprecations? yes/no
New tests added? yes/not needed
Fixed tickets Fixes #ticket number (set to none if no tickets are fixed, repeat template for each ticket fixed)
License MIT

Description

[Description of the bug or feature]

This commit fixes issue #1 where the editor would incorrectly prompt to save
files upon closing, even when no local modifications were made.

Problem:
- When a file was externally modified on disk, the code unconditionally set
  isSaved = false, causing the "unsaved changes" prompt even for unmodified files

Solution:
- Distinguish between "file already saved" and "file has local changes" states
- If file is saved: silently load external changes with info notification
- If file has unsaved changes: prompt user whether to reload

Also added:
- USAGE_GUIDE_CN.md: Chinese usage guide documenting that multi-window and
  PDF export features already exist in the application

Changes:
- src/renderer/store/editor.js (lines 1169-1195): Fixed file change handling logic
- USAGE_GUIDE_CN.md: New documentation file
Added MAC_BUILD_GUIDE_CN.md with detailed instructions for building and
packaging MarkText on macOS, including:
- Prerequisites and system requirements
- Step-by-step build instructions
- Development mode setup
- Troubleshooting common issues
- Advanced build options
- Output file descriptions

This guide helps users build DMG and ZIP packages for both Intel (x64)
and Apple Silicon (arm64) architectures.
Added INSTALL_FROM_REPO_CN.md with multiple installation methods:
- Automatic build via GitHub Actions (release-v* branches)
- Homebrew Cask installation
- Direct download from GitHub Releases
- One-click install scripts
- CI/CD automation setup

This guide helps users install MarkText without manual building by
leveraging the existing GitHub Actions workflows.
Modified release.yml to trigger automatic builds for branches starting
with 'claude/', in addition to 'release-v*' branches. This allows the
release workflow to run on feature branches for testing and distribution.
Added comprehensive documentation:
- HOMEBREW_INSTALL_CN.md: Complete guide for installing via Homebrew,
  including methods to override official cask and create custom tap
- DOWNLOAD_CN.md: Full download page with all platform download links,
  installation instructions, and file checksums
- README_FIXES.md: Summary of fixes and quick start guide

These docs help users easily install the fixed version via multiple methods.
@stevenchenUCD

Copy link
Copy Markdown
Author

bug fix by claude

@SPetersonNICE

Copy link
Copy Markdown

There might be an extra factor here triggering the modified flag. When a file created elsewhere is opened, MarkText will auto-insert blank lines in a document below headers and at certain locations, silently modifying the file. Thus the "modified flag" is accurate, despite the user not making and not wanting any changes, the file has been changed. #3772

@dimpen

dimpen commented Feb 24, 2026

Copy link
Copy Markdown
image

Does this setting have anything to do with the newlines being added?

Whatever option I set it to the newlines are always added.
This creates the issue where opening a file modifies it and thus produces the annoying save on exit dialog.

Also what is the difference between Preserve style of original document and Do nothing?

UCHIHAHA103 pushed a commit to UCHIHAHA103/marktext that referenced this pull request May 14, 2026
…ll position / XSS / contextIsolation

- fix: 编辑菜单截图分割线仅 macOS 可见(Windows 不再出现双分割线)
- fix(marktext#4093): 深色主题打开窗口预设背景色,消除白闪
- feat(marktext#4134): capitalizeAccelerator - 自定义快捷键修饰符大写修复
- fix(marktext#4146): 搜索打开文件后首次 muya 序列化不触发未保存状态
- fix(marktext#4075): 外部文件变更:已保存时静默加载,未保存时才提示
- fix(marktext#4152): 切换 Tab 保留滚动位置;打开文件光标定位到开头
- fix(marktext#4206): 图片属性 HTML 转义防 XSS/RCE
- fix(marktext#4192): contextIsolation=true 防渲染进程调用 Node.js API
@Jocs

Jocs commented May 15, 2026

Copy link
Copy Markdown
Member

This project recently merged a large refactor (electron-vite migration, PR #4001) that upgraded dependencies and fixed several issues.

Please review this PR and let us know if it is still needed, or if the changes have already been addressed upstream.

Note: This PR currently has merge conflicts with the develop branch. If you decide to continue with this PR, please rebase or merge the latest develop branch to resolve the conflicts before it can be reviewed.

@Jocs

Jocs commented May 20, 2026

Copy link
Copy Markdown
Member

Thank you for the contribution. After review, we're closing this PR for two reasons:

  1. The same issue (false "unsaved changes" prompt when closing an unmodified file) is also being addressed in fix: avoid false "unsaved" prompt when closing file opened from search without editing #4146 with a more focused diff against src/renderer/src/store/editor.js.
  2. This PR includes a number of unrelated files — translated docs (DOWNLOAD_CN.md, HOMEBREW_INSTALL_CN.md, INSTALL_FROM_REPO_CN.md, MAC_BUILD_GUIDE_CN.md, USAGE_GUIDE_CN.md), README_FIXES.md, and changes to .github/workflows/release.yml — which make it difficult to review as one change.

Closing in favor of #4146. If you'd like to contribute the unsaved-prompt fix or any of the other changes, please open separate, focused PRs against the latest develop branch — we'd be happy to review them.

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.

5 participants