mockko / livereload

LiveReload applies CSS/JS changes to Safari or Chrome w/o reloading the page (and autoreloads the page when HTML changes)
http://livereload.com/
1.18k stars 56 forks source link

Vim Doesn't Play Nice With LiveReload #11

Closed aguynamedryan closed 14 years ago

aguynamedryan commented 14 years ago

When writing changes to disk, vim sometimes seems to delete and recreate the file rather than just modifying it. I'm not certain why vim does this, but I'm not inclined to crack open vim's source and change it.

Instead I've modified livereload so that it will send a refresh command to the browser when livereload detects a newly added file. This behavior seems pretty harmless because, in the case of vim, the "newly added file" is really just a modified file, and the browser will refresh the file since the browser already has a copy of the file located in the DOM. For files that are genuinely new, never-before-seen files, the browser extension won't find a file to update in the DOM and instead will refresh the entire page, which seems to be correct behavior to me.

This is really only half the battle though. DirectoryWatcher only checks for new files every 30 seconds. This interval is far too long to detect files that vim has removed and recreated, so I added a config.interval option which allows me to set the interval to something more like 1 or 2 seconds.

I've put the config.interval and send refresh on file add in this branch: http://github.com/aguynamedryan/livereload/commit/beb83d83564ec9d1114632098826e39aa9a82e99

If you only want the config.interval changes, they are in this branch: http://github.com/aguynamedryan/livereload/commit/5fb13814d4166f4eb0bf28be56420c93e717eb32

If you only want the changes to send refresh when files are added, they are in this branch: http://github.com/aguynamedryan/livereload/commit/282b80534dd79c88152d7b4774c6b1af0232e999

andreyvit commented 14 years ago

I guess this boils down to:

andreyvit commented 14 years ago

Vim should now work with LiveReload 1.4. Please update and test.