Idle-only document change listener


Usually when the user is typing, the IDE waits for the user to stop (for a duration of 0.5~1s) before firing some heavier operations like reparsing, which results in better overall performance. I want to handle document changes in the same way in my custom language plugin, but with the traditional `document.addDocumentListener(new DocumentListener() {...})` the listener is notified of every single change.

Does the API provide an easy way to register such idle-only document change listeners? If not, what would be the simplest way to manually implement this behavior?



See com.intellij.util.ui.update.MergingUpdateQueue


Thanks! I can see that the class has a lot of public methods and very little documentation so it's a little hard to get started with. Could you please give a simple example usage or at least explain more or less how to use it? That would be great :)


Aren't there usages in IDEA community?


Please sign in to leave a comment.