-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
entr should not break on rename #298
Comments
Nice debugging. Perhaps try putting in a short sleep and see if that fixes it? Code for |
Indeed – it's still quite close to my version, so that should be fine. I started looking at it, but was (1) a bit uncertain about what the behavior should be, and (2) a bit uncertain about how to add the appropriate tests :-} I'm not sure how a sleep would work, though. The returned event will still indicate that the file has been renamed, no? That's information we get from the As far as I can see, the event returned is identical, regardless of whether a new file overwrites the one we're tracking or if the tracked file is renamed to something else (i.e., it's a The behavior of entr is:
I'm not sure what the right thing is in case 3. One possibility is to not do anything particular – we'd end up with an error once we try to keep tracking changes after it's gone, anyway, and the resulting So: My suggestion would actually be simply to the conditional break when Whether we should add a single unconditional triggering of the function before we look for changes, I don't know. It might be useful to follow the behavior of the original tool, perhaps. At least for my code, this is sensible behavior, because I generally use it to generate some output, and though I'd like to re-generate the output when my code and input files change, I usually also want an initial version of the output when I start. But if you want to indicate changes, maybe you don't want that… |
I haven't looked carefully. The recommendation to add a sleep was motivated by the assumption that the rename is transient, and if you wait a little there will be a second event that does something different. Maybe not true? Sorry, in meetings, can't look now. |
As far as I can see, that's not the case. The change is the file being overwritten – which I guess is then signalled as a rename, even though it's technically a rename of a different file, and a deletion of the one we're watching. And from my (simple) experimentation, it seems like there is just one change event triggered – which is how it should be, as it only changes once. My previous comment was a bit verbose, but simply put, I simply suggest removing the special-casing of |
The same semantics, that is, once we've gotten going; the command-line tool also triggers once before it start watching for changes. However, it has the comand-line switch
Whether that should be the default, an option or unavailable behavior in |
For the first change, I'd approve running the update whenever the status is The second seems reasonable too. I'd do it via a keyword argument. |
Okay, tested this out, now, and it works just fine – but it doesn't seem to solve my problem; when I save from either vim or emacs, I end up with two events, now. That is true even if I make However: The In my code I added a keyword argument for the length of a pause to be taken after |
A PR would be great. One way to flexibly handle those double-triggers is to set up a flag indicating that an update is scheduled, e.g. const entr_update_scheduled = Ref(false)
# in entr body
if !entr_update_scheduled[]
entr_update_scheduled[] = true
@async begin
sleep(0.02)
entr_update_scheduled[] = false
revise()
f()
end
end With this it will wait 20ms before running the update, thereby giving editors a chance to finish making all their changes. Because we check |
Seems like a good idea in principle, but it doesn't quite seem to do the trick. At least, I still end up with several calls (for some reason I got 3 calls, now). In my previous version, even a sleep of 1 second wasn't enough – though 2 worked. Because it was so long, I put it after the call to Now, I just tried to repeatedly log the output of
There may be several ways of reasonably using a small cluster of file system operations to modify a file, in cases where we only want to trigger once. Maybe the only solution is to have a moratorium after a call to And I guess it has to be user-definable (if this is the way to go); in my current tests the callback is generally quite trivial, but if the callback itself takes a while to run, there is of course less of a problem anyway. |
Since I basically never use |
OK, I'll have a go. |
Was this fixed by #308? If so please close. |
Indeed, it was :-) |
I was puzzled for a while about why I couldn't get
Revise.entr
to work – every time I modified a file, it just quit. Then I realized it was because my editor (vim
) uses two-stage saving, where it writes to a temp file and then moves that to overwrite the original. And I don't think that is a situation whereentr
should conclude that the file is no longer relevant; indeed, this works just fine with the originaleentr
command-line tool.I'm not sure exactly what the behavior should be – e.g., if
renamed
is also true if the original file is renamed to something else (in which case we might not want to keep watching it), but at least for my use-case (editing withvim
), the current behavior is not helpful.The text was updated successfully, but these errors were encountered: