auto dedent the closing bracket after press ENTER key


I'm working with my custom language plugin, and it's an **indent-based** language. I want to save time when typing indent/dedent, so I've implemented my `BraceMatcher` and `LineIndentProvider`.

It's strange that after typing enter in parentheses() and braces{}, it works fine. BUT when it comes to the brackets[], the closing bracket does not dedent as expected, just as the following example: ( | means the position of the cursor)

# for braces, works fine:
a = {|}
# then I press enter between the two braces, it will be:
a = {

# for parentheses, works fine:
a = (|)
a = (

# ----------------------------------------
# BUT for brackets, things just go wrong:
a = [|]
a = [

I'm confused because I didn't treat the bracket any differently than parentheses and brace. I guess there may be something done in the EnterHandler, but I can't find it precisely.

Could you please explain why the bracket behaves differently and how to solve the problem? Thanks very much!

1 comment

I find this post: , and it inspired me to register the enterBetweenBracesDelegate EP with EnterBetweenBracesAndBracketsDelegate:

<enterBetweenBracesDelegate language="KCL"  implementationClass="com.intellij.codeInsight.editorActions.enter.EnterBetweenBracesAndBracketsDelegate"/>

it worked and I think I've found where the magic happens!


Please sign in to leave a comment.