Invocation of 'paste' operation for specific caret is not supported


Hi there,

users and I have noticed the following exception

java.lang.AssertionError: Invocation of 'paste' operation for specific caret is not supported
at com.intellij.codeInsight.editorActions.PasteHandler.doExecute(
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(
at com.systema.eia.misc.PasteLinkHandler.doExecute(
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(
at img2md.PasteImageHandler.doExecute(
at img2md.PasteImageHandler.execute(
at com.intellij.openapi.editor.impl.EditorImpl.lambda$handleDrop$17(
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(
at com.intellij.openapi.editor.impl.EditorImpl.handleDrop(

Essentially what I'm doing is

public void execute(Editor editor, DataContext dataContext, Producer<Transferable> producer) {
Caret caret = editor.getCaretModel().getPrimaryCaret();
doExecute(editor, caret, dataContext);

and in doExecute:

 myOriginalHandler.execute(editor, caret, dataContext);

The myOriginalHandler is passed as a constructor parameter

It's not much code in total anyway, which you can find at

Do you have an idea what could cause the exception, and how to address it in my plugin's implementation?

Thanks in advance,

best regards,



doExecute can be called with null meaning perform for all carets in the editor or can be called for individual carets of the editor (multi-caret mode).

Some action handlers do not support operations for specific carets since they handle all carets themselves. Using getCurrentCaret() should take care of it.

Short story, try using editor.getCaretModel().getCurrentCaret() instead of getPrimaryCaret(). This will be null if there is no current caret (ie. not in caretModel().runForEachCaret()) I think null could be used instead but I am not sure of this for all cases of paste handler.



`editor.getCaretModel().getCurrentCaret()` will never return `null` (if there's no `runForEachCaret()` call, the primary one will be returned).

Just pass `null` as `caret` to `myOriginalHandler.execute(editor, caret, dataContext);` call.


Thanks for your help. I've updated the plugin accordingly.