adrienkohlbecker / vagrant-fsnotify

Forward filesystem change notifications to your Vagrant VM
MIT License
139 stars 15 forks source link

The file has been changed since reading it #36

Closed jchook closed 9 months ago

jchook commented 9 months ago

Often when I try to save a "watched" source file in neovim, I get this warning:

WARNING: The file has been changed since reading it!!!

I'm unsure of the exact cause of this bug. However, this behavior seems basically expected:

  1. nvim modifies the file
  2. vagrant-fsnotify touches the file, setting the modification date past neovim's known file modification date
  3. nvim tries to modify the file, but throws a warning because of the modification date difference

And I think it does not occur in a sequence like this:

  1. nvim modifies the file
  2. vagrant-fsnotify does not touch the file because of a debounce
  3. nvim modifies the file

However, I saw the touch command supports the -d parameter:

       -d, --date=STRING
              parse STRING and use it instead of current time

It would be great if we could somehow subtract a second or something from the modification date.

jchook commented 9 months ago

It looks like there are some known issues with this "file has been changed" warning related to NFS and Samba shares, so this may not be related to fsnofiy.

See:

I have temporarily resolved the issue by remapping my :write shortcut to :write!.