Merged
Conversation
Contributor
|
@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! |
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.
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:
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_timeouteliminates the need for thelast_reloadfield and all the logic arround it.