Repository navigation
fix(desktop): ignore content-identical file-change events - #4760
Merged
Merged
Conversation
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]>
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
force-pushed
the
fix/1861-filechange-content-check
branch
from
June 27, 2026 04:25
95a996b to
bcaa6a0
Compare
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A file watcher
changeevent fires whenever a file's mtime changes — even when the content is byte-identical (e.g. agit checkoutthat 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/addhandler, 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 realmt::update-filehandler:lint + typecheck clean.
Fixes #1861