How to indent comments and new-lines in a block

I am able to indent block-content which is surrounded by special keywords. But I got the issue that comments inside a block are not indented. In addition to that I am wondering why a new-line is not indented as expected.

I expect that the indent of a comments and new-line is aligned to their belonging block-content.

Below you see a screenshot of the current indent behaviour: The new-line in line 24 is indented to the parent block instead of the block-content. Same problem for the comments in line 25 and 26. I expected them to be indented as line 23, 27, 28 and 29

In my BNF I defined a Objects and ObjectChildren (~block-content) like this

The managing of the indents is straight forward done in the AbstractBlock's getIndent method implementation

I tried a lot, e.g. indenting the comments in the AbstractBlock's getIntent() method or add special behaviors in the FormattingModelBuilder's createSpaceBuilder() method.

The whole code is hosted on Github: https://github.com/dnltsk/intellij-mapfile-plugin/tree/master/src/org/dnltsk/mapfileplugin/formatter

What is the trick to indent comments and new-lines within the block-content?

Thanks for any hint!

1
1 comment
Avatar
Permanently deleted user

I solved the comment indent by counting the depth and manage the comment's indent in condition to the it.

Last open point is the correct indent of the new-line cursor position.

Thanks for any help!

Cheers

0

Please sign in to leave a comment.