YAML plugin doesn't support injection so I'm implementing custom PsiLanguageInjectionHost for YAMLScalarList.
It is simply a delegate for YAMLScalarList with two additional metods required by injection host - updateText and createLiteralTextEscaper. I've implemented MultiHostInjector using InjectionUtils like in XmlLanguageInjector:
InjectorUtils.registerInjection(GroovyFileType.GROOVY_LANGUAGE, Collections.singletonList(injectionTrinity), context.getContainingFile(), registrar);
Now, intention actions works fine, i.e. variable introduction, but I have problem with editing - when I press Enter, then caret in editor goes to the beginning of injection range or at the end of it. Example:
script: |<beginning of Groovy injection><caret position after 'enter'>
<caret position before 'enter'>def a = "";<or caret position after 'enter'><end of Groovy injection>
There is no exceptions in IDEA logs.
Could You give me some hints what should I inspect to resolve this problem?