How does listening to document changes works?


My purpose is to receive for every update in one of the editors (including Ctrl-Z, selection delete, etc...) the text of the file. That way I can find the difference that occurred in the last update, and send it out of the plugin to my server. I read Documents | IntelliJ Platform Plugin SDK ( which tells you how to check for changes.

- I understand FileDocumentManagerListener but it only gives access to updates every save, which does not happen for every change.\

- EditorFactory.getEventMulticaster().addDocumentListener()  might be what I need but I don't get how to use it. Since you can't just run your own code, it must be connected somehow to the plugin.xml or files like that. I can't just run it... Is there any example for that?


Every help would be very appreciated! 

1 comment

You may try registering a Project Service which will get access to editors and opened documents.


Please sign in to leave a comment.