Skip to content
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

Notify when a file/folder is created/changes/reloads/disapears, even if not opened #626

Open
titoBouzout opened this issue Jan 4, 2015 · 6 comments

Comments

@titoBouzout
Copy link
Collaborator

Would be very nice to add an API call/event for when a file or folder changes that includes all events: creation/modification/deletion. This for example will allow to fire things when something changes, as re-parsing a file or something. Currently we need to crawl the complete tree in intervals, I guess this is something ST already does..

@titoBouzout
Copy link
Collaborator Author

My real World example is that I need to check the content of a file when a new view/tab is loaded. I need to open/read and parse that file every-time a file is opened, not good!

@FichteFoll
Copy link
Collaborator

You could compare against the file's modified date instead as that will be quicker than reading and comparing the entire file. It might be less reliable but definitely quicker and easier on the storage.

I'd flag this as a feature request not an enhancement as such a feature does not exist for plugins so far and we don't know how ST watches its package files.

@kans
Copy link

kans commented Mar 30, 2015

I was about to file this exact issue. The ST Floobits plugin adds support for real time collaboration for every file in the project - not just the opened views (in order for builds to work on both sides). Frequently, files are edited outside of ST which causes us quite a bit of trouble. ST already indexes the files and watches them. Reimplementing file scanning ourselves would be quite a bit of work and a poor user experience.

Scanning eats up both disk IO and CPU; moreover, its async so our plugins view and ST's view would be ... out of sync. ST should expose the file events via the Listener API. IntelliJ exposes both types of events and offers a good example of how to do it. All file-like objects are exposed via VirtualFiles; the files can map to files on disk, objects in a zipped bundle, or remote files. Users edit Documents (ST Views) which are backed by VirtualFiles. VirtualFiles can be saved, moved, deleted, written, reloaded, etc.

@opsidjflksdf
Copy link

I was looking for a solution to the same problem.
I came across this (not my code):
https://github.com/russelldavis/sublime-detect-deleted-files

  • it closes tabs for which the file has been deleted (or renamed/moved away), or shows a warning (and not close) if there have been changes. It's a bit rough around the edges, the dialog shows up multiple times, can probably be improved, but overall it seems like it's on the right track.

To use it, create a folder with any name under under Data\Packages and place the .py file in that folder.

@rchl
Copy link

rchl commented May 1, 2020

This looks like a duplicate of #2669

@FichteFoll
Copy link
Collaborator

#2669 is about resource files. This issue is about files in a project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants