Detours Document changes

Hey, is there a way to detour document changes?
I am trying to catch up all changes to a document before they are applied to it.
I know that it is possible to register a DocumentListener but this way i can't prevent the changes to be applied to the document.
I've allready tried it by setting up a new handler to TypedAction: EditorActionManager.getInstance().getTypedAction().setupHandler()
But the problem with this solution is that changes done by shortcuts, for example [CTRL]+[J], are not registered.

Is there another possibility to get noticed when changes to a document are tried to be done and to prevent them from happening?

4 comments

What are you trying to achieve?

0

As stated above i want to get notified when changes are done.
Then i want to decide whether this change should be forwarded or not.
When using a listener i am not able to block these changes.

0

Hello,

I'm afraid there is no such a facility at the moment. There is a com.intellij.openapi.editor.Document.createGuardedBlock() method which allows to protect particular document range from modification but there is no 'vetoable document change' processing.

Denis

0

What you describe is not the problem, but a specific solution for the problem that you have in mind, which is not possible to implement within IntelliJ IDEA's design. If you could describe the original problem you're trying to solve, we could possibly suggest an alternative solution that would work better with our architecture.

0

Please sign in to leave a comment.