Skip to content

fix(desktop): ignore content-identical file-change events - #4760

Merged
Jocs merged 2 commits into
developfrom
fix/1861-filechange-content-check
Jun 27, 2026
Merged

Jocs merged 2 commits into
developfrom
fix/1861-filechange-content-check

Conversation

@Jocs

@Jocs Jocs commented Jun 27, 2026

Copy link
Copy Markdown
Member

Summary

A file watcher change event fires whenever a file's mtime changes — even when the content is byte-identical (e.g. a git checkout that switches to a branch where the file is unchanged). MarkText then marked the tab unsaved and popped a spurious "file changed on disk" prompt for a no-op change (#1861).

Fix: in the change/add handler, skip the work when the new on-disk content equals the tab's current content.

Verification

Editor-store unit test (file-change-content-check.spec.ts), RED→GREEN — drives the real mt::update-file handler:

  • content identical → no prompt, tab stays saved
  • content actually changed → prompt shown, tab marked unsaved (unchanged behavior)

lint + typecheck clean.

Fixes #1861

A watcher 'change' event fires whenever a file's mtime changes, even when
the content is byte-identical (e.g. a git checkout that touches the file
without changing it). The handler then marked the tab unsaved and showed a
spurious 'file changed on disk' prompt. Skip the change when the new
on-disk content equals the tab's current content.

Fixes #1861

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

Build artifacts for PR #4760:

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

Artifact Size Link
marktext-windows-arm64 275.7 MB Download
marktext-windows-x64 283.8 MB Download
marktext-linux 627.4 MB Download
marktext-macos-x64 293.0 MB Download
marktext-macos-arm64 282.7 MB Download

End-to-end coverage that drives the REAL watcher: it writes the actual
file with byte-identical content and lets the main-process chokidar
watcher -> loadMarkdownFile -> renderer handler run, asserting the tab
stays clean; a genuinely different write still marks it unsaved. (An
earlier draft hand-crafted the IPC payload, which matched tautologically
and proved nothing.)
@Jocs
Jocs force-pushed the fix/1861-filechange-content-check branch from 95a996b to bcaa6a0 Compare June 27, 2026 04:25
@Jocs
Jocs merged commit af6d792 into develop Jun 27, 2026
10 checks passed
@Jocs
Jocs deleted the fix/1861-filechange-content-check branch October 23, 2026 08:32
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.

Filter “file changed on disk” for timestamp changes

1 participant