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

Smart file watching #24

Open
fogzot opened this issue Mar 9, 2016 · 3 comments
Open

Smart file watching #24

fogzot opened this issue Mar 9, 2016 · 3 comments

Comments

@fogzot
Copy link
Contributor

fogzot commented Mar 9, 2016

As discussed in #19 and other issues watching the full solution tree sometimes results in too many open files errors, especially when one uses client-side package managers like npm or bower. A solution could be to watch single directories, excluding problematic ones. My idea is to:

  1. Extract project structure information from both the solution file and the top-level global.json "projects" key and use a bit of euristic (see later) to determine which subdirectories should be watched for changes.
  2. Look for exclude patterns in each subdirectory: this could be made configurable but ignoring node_modules, bower_packages and other well-known names is probably a good start.
  3. For each subdirectory that doesn't contain anything to ignore just create a single watcher.
  4. For each subdirectory that contains something to ignore creare a top-level watcher with IncludeSubdirectories set to false and then one watcher for every directory.

We will end up with more watchers than strictly necessary but, given that one usually doesn't have tens of directories inside each project, not that much more.

Does this seems sensible or am I missing something?

@mrward
Copy link
Owner

mrward commented Mar 9, 2016

It would need to handle new directories that get created or new projects being added. I wonder if there is any problem creating lots of individual file watchers.

I am still tempted to just rely on the IDE detecting file changes since this feature already exists and may be simpler to implement. It also completely fixes the too many files problem.

@fogzot
Copy link
Contributor Author

fogzot commented Mar 9, 2016

I fear that the IDE will not detect files added from the outside but I don't know about this part of MonoDevelop: which files exactly does it watch?

@mrward
Copy link
Owner

mrward commented Mar 9, 2016

Yeah I agree it may not detect files added outside the IDE.

How often does adding files outside the IDE happen in practice? I was assuming that if you are in the IDE then you are adding new files using the IDE.

The IDE will detect files that have changed that it knows about. For example if you edit a .csproj file outside the IDE when you switch back to the IDE it knows the file has changed and will reload the project file. New files are different problem. This could be handled by rescanning the directories when the IDE receives focus again. Or maybe this is not automatic and instead the user can refresh a directory themselves in the solution window.

Right now if you add a new directory or files the solution window will not be updated even though the file watcher will detect this and be sending the files to the DNX host. However this is just something that was not yet implemented.

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

No branches or pull requests

2 participants