Trying to replace COPY_HANDLER for an editor

Answered

I cannot find a way to supply a custom copy handler to an editor. The DataContext of the copy action always resolves to the EditorComponent and I can see no way to override. I am usually good at navigating mazes but cannt find a way to solve this. Please advise!

0
4 comments

Could you please give more details about what you're trying to achieve? Maybe registering CopyPastePostProcessor or CopyPastePreProcessor (namings are a bit obscure) can solve your problem.

0
Avatar
Permanently deleted user

I have a LanuageConsole and am trying to make it so when the user copies code from the history view the prompt doesn't get copied. CopyPastePreProcessor only gets invoked if the editor has an associated PsiFile, which is not the case here.

0

You can register an EditorActionHandler for "EditorCopy" action. In it you can detect whether it's invoked in your context and perform any required actions. If it's invoked in other context, you should delegate to the original handler (like com.intellij.codeInsight.editorActions.CopyHandler does).

0
Avatar
Permanently deleted user

This works! Thanks!

The only minor annoyance is that it puts a little bit of overhead on all editors. 

0

Please sign in to leave a comment.