Scoping a command with a selector

Hi! I’m trying to add a simple text command to my extension to override the behaviour of the return key within documentation comment blocks, so that it prepends the comment characters to new lines for convenience.

The code is in this commit and works fine, except that it overrides the behaviour of the return key everywhere, which leads to the loss of other conveniences like automatically generated closing braces in code blocks.

Being able to fall back on default behaviour in code, as requested here, would be one solution, but another would be to scope the command so that it only applies in comments.

I can’t see a way of doing this with filters or when-clauses. Have I missed something? If not, could this be considered a feature request please? :slight_smile: