Skip to content

fix live reloading#49

Merged
nicholasjpaterno merged 1 commit intoEpistates:mainfrom
enzalito:fix-reload
Mar 11, 2026
Merged

fix live reloading#49
nicholasjpaterno merged 1 commit intoEpistates:mainfrom
enzalito:fix-reload

Conversation

@enzalito
Copy link
Contributor

The live reload feature only watches for events on the current file. This is ok in most cases, but some editors (e.g. Helix) use the following strategy to perform atomic saves:

  • rename file (file.md.bak)
  • create new file (file.md)
  • fill new file
  • delete backup

This is a problem because the new file corresponds to a different inode so the watcher won't catch its events (and the screen won't be refreshed).

Watching for events on the parent directory is, imo, the most elegant fix.

I also simplified (and improved) the debouncing mechanism. Instead of ignoring reloads that are triggered too soon after another reload (which could result in a stale file beeing displayed if I'm not mistaken), we wait a few ms for new events before triggering the refresh. Using Receiver::recv_timeout eliminates the need for the last_reload field and all the logic arround it.

@nicholasjpaterno
Copy link
Contributor

nicholasjpaterno commented Mar 11, 2026

@enzalito Thanks again for another contribution! This is definitely the right call, theres a few changes (the recv_timeout blocking and the broken unwatch) I'm going to make as a fast followup but I'm going to merge this one in as is for now! Thank you!

@nicholasjpaterno nicholasjpaterno merged commit 10cdeaa into Epistates:main Mar 11, 2026
1 check 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.

2 participants