See bug #190675 comment #7. A major limitation of the Linux FS notifier using inotify is that Linux distributions typically set the fs.inotify.max_user_watches to 8192 by default, too small for watching a big tree. You can increase your limit manually but most people will not have done so.
One possible way around this limitation might be to cheat a little and open additional file handles when you run out of watches on the first handle. Would make the implementation more complex, but could greatly expand the limit.
Marking as a DEFECT since the current implementation does not even check the return value of inotify_add_watch - so if you run out of watches, the IDE will just silently not listen for additional changes, until some recursive listeners are removed.
Reporting errors during add_watch: ergonomics#74b0a4008588, making enhancement.
Calling select via JNA seems impossible (one cannot call FD_XXX macros). Using poll looks much easier.
Created attachment 107930 [details]
Multiple PollFd instances
Here is a patch that allocates new instances of inotify, but as soon as first one hits a limit, all of the new ones return -1/28 error too. Looks like the inotify limit is per user/process in spite what documentation says!?
If you can find out why the patch does not work for me, that would be great.
Looks like Jesse's suggestion does not work.