Request: migration guide for multiple carets in 13.1

I've been looking at the changes required to support multiple carets in 13.1, and I've been thinking that it would be really useful to have a migration guide for them. The Javadoc is great (thanks!) but there are still quite a few things that are not clear to me - it would be good to get all the answers together in a document under since most people with non-trivial plugins will have the same questions. I can see how to update all my EditorActionHandlers (and thus EditorWriteActionHandlers etc), that looks pretty straightforward.

  1. I have a TypedActionHandler which doesn't seem to have built-in support for this. I'm assuming I should define a CaretAction and use runForEachCaret from the editor's CaretModel?
  2. What about other entry points such as EnterHandlerDelegate and so on - should they use the same mechanism? This seems more complex because it passes caretOffsetRef and caretAdvance, it's not clear how those interact with this.
  3. I also use AutoPopupController.autoPopupParameterInfo - how should I handle that?
  4. In general, it's not clear to me how this functionality interacts with things that seem intrinsically tied to a single caret, like parameter info, code completion, doc lookup etc. Would it be possible to explain this? Do these just use the main caret?

I'm sure I'll have plenty more questions, but these are what I came up with. In general, this seems like a pretty massive change that'll break a fair few third-party plugins, it would be great to make the migration as easy as possible.

2 comments page has just been added to the plugin development guide. I hope it answers some of your questions. Please feel free to add additional ones in page comments.

Some additional comments to your questions:

1) Yes, you can use CaretModel.runForEachCaret to add support for multiple carets in your handler, or e.g. use EditorModificationUtil.typeInStringAtCaretHonorMultipleCarets method.
2) EnterHandlerDelegate implementations don't need any changes - they are invoked for each caret now, but, due to existing issues with this approach, this will most probably change soon (to work the way typed handers work now).
3) AutoPopupController.autoPopupParameterInfo works only for primary caret now (it works asynchronously, so it ignores runForEachCaret context).
4) As you say, such cases are suposed to use the primary caret.


Thanks Dmitry, this is very helpful.


Please sign in to leave a comment.