Skip to content

feat: add autoReloadOnFileChange preference - #5325

Closed
dronov-dmitry wants to merge 5 commits into
marktext:developfrom
dronov-dmitry:develop
Closed

dronov-dmitry wants to merge 5 commits into
marktext:developfrom
dronov-dmitry:develop

Conversation

@dronov-dmitry

@dronov-dmitry dronov-dmitry commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add a new preference autoReloadOnFileChange (default: false) that automatically reloads file content when changed on disk by an external process, bypassing the confirmation dialog.

Demo

Auto-reload on file change setting

🎬 Video demo

Changes

  • schema.json: New autoReloadOnFileChange boolean preference
  • preferences.ts (types): Type definition in IUserPreferences
  • preferences.ts (store): Pinia state type + default value
  • editor.ts: New branch in LISTEN_FOR_FILE_CHANGE() — when enabled, reloads immediately without dialog regardless of autoSave state
  • preference.json: Default value for persistence across restarts
  • general/index.vue: UI toggle in General preferences
  • locales: English translations

Behavior

Setting autoReloadOnFileChange autoSave Result
Default false false Shows confirmation dialog
Auto-save on false true + saved Auto-reloads (existing behavior)
Auto-reload on true any Always auto-reloads, no dialog

Why this change?

When working with files that are frequently updated by external processes (server sync, git pull, live-reloading tools), the constant "File was changed on disk. Do you want to reload it?" dialog is disruptive. This setting allows the user to opt into silent auto-reloading.

Persistence fix

Initially the autoReloadOnFileChange preference did not survive app restarts. The root cause: Preference.init() in the main process compares saved user settings against static/preference.json using hasSameKeys(). Since the new key was missing from preference.json, it was treated as an outdated key and deleted, then re-added with the default false. Fixed by adding autoReloadOnFileChange: false to preference.json.

Testing

  1. Enable Auto-reload on file change in Preferences > General
  2. Open a markdown file
  3. Modify it externally (e.g. echo test >> file.md)
  4. Content should reload automatically without dialog
  5. Disable the setting → dialog should appear again
  6. Restart the app → setting should persist

Add a new internal preference 'autoReloadOnFileChange' (default: false)
that automatically reloads file content when changed on disk by an
external process, bypassing the confirmation dialog.

When enabled, the file is reloaded immediately regardless of autoSave
state. When disabled (default), existing behavior is preserved:
- autoSave enabled + file saved → auto-reload
- otherwise → show confirmation dialog
The autoReloadOnFileChange preference was not being saved/loaded properly.
On startup, Preference.init() compares user settings with preference.json
using hasSameKeys(). Since autoReloadOnFileChange was missing from
preference.json, it was treated as an outdated key and deleted from the
user's saved settings, then re-added with the default value of false.

Added autoReloadOnFileChange: false to preference.json so the key is
recognized and the user's saved value is preserved across app restarts.
@Jocs

Jocs commented Sep 14, 2026

Copy link
Copy Markdown
Member

dup with #5174

@Jocs Jocs closed this Sep 14, 2026
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.

2 participants