New Line does not match Indent / Alignment of previous line.

I think I'm missing some fundamental aspects of how indentation and alignment formatting work.  I read over the code formatting section of the custom language development guide, but I couldn't find the answer there.  I wrote another post here a few days ago with more details. 

Long story short, here's an example of what code in my language should look like this when properly indented.  ("." and "->" represent leading spaces and tabs respectively in all examples.)

(main_operation
->(sub_op_1 param_1 param_2)
->(several (chained (ops
->->param_3
->->param_4
->)))
)

Each line is always either one level deeper/shallower than the previous line or else on the same indentation level.

The getIndent method inside my Block implementation returns the expected result when I use Ctrl-Alt-L to format my document.  However, when I'm typing code inside the editor, new lines are not properly indented.  This is what happens.  Consider a very simple piece of code, with "|" representing my cursor on the end of line 2.

(main_operation
->param_1 |
)

When I hit enter, I want my cursor to move to line 3 and line up with the code on the previous line, like this.

(main_operation
->param_1
->|
)

But instead of a full indent, the new line is just indented by a single space.  The cursor lines up with the text "main_operation" instead of indenting as expected.

(main_operation
->param_1
.|
)

If I immediately use Ctrl-Alt-L to format my document, I get the desired outcome with the cursor lined up with the previous line of code.

So, my question is, why doesn't the newly created line get the expected indentation?  Can I force the formatter to run after the new line is added?  

Bonus question: when I use an insert handler, the resulting text is not indented at all.  Again, can I force the formatter to run after my completion contributor is invoked?

1
3 comments
Avatar
Permanently deleted user

I have been using Intellij for 4 hours now. What a waste of time. Never in 30 years have I met such a terrible IDE. I never like Eclipse, but I hate Intellij.

-8
Avatar
Permanently deleted user

did you find a solution? I am seeing the same thing and not sure how to fix this

1
Avatar
Permanently deleted user

Yeah.  I realized the problem was with Alignment, not Indent.  See my last reply in this thread: https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000556724-Custom-Language-Indent 

0

Please sign in to leave a comment.