Can I suppress/disable XmlAttributeInsertHandler conditionally?

已回答

This may seem like an odd request, but I'm adding support in my plugin for a new markup language where sometimes an HTML attribute value should look like {value} instead of "value". By default when you accept an attribute code completion, XmlAttributeInsertHandler adds ="<cursor-here>" after the completed attribute name.

This can be disabled globally, but that's probably not ideal because it would mean more typing required by the user when working in other XML/HTML files.

With this behavior enable, the user is forced to backspace, type open brace ({), the actual attribute value, and close brace (}). I can add a typedHandler implementation to pair the open/closed braces in this scenario to ease things a bit, but the backspace would still be required which is pretty annoying.

I've looked at the XmlAttributeInsertHandler source to see if there might be some way to suppress this behavior conditionally via some other EP, but I'm not seeing anything obvious. Before I punt altogether, I thought I'd check here and see if anyone knew about something I'm not finding that might help in this situation.

Thanks in advance!
Scott

0

You can implement your own CompletionContributor, register it with  order="before xmlNonFirst",

and use XmlAttributeReferenceCompletionProvider.addAttributeReferenceCompletionVariants 

with your custom InsertHandler and call CompletionResult.stopHere().

1

It's been a while since I posted this question, but I did finally get around to implementing the suggested approach and it worked great! Thanks, Dmitry!

0

请先登录再写评论。