Formatting Block to indent relative to where its parent would be
Hello,
I'm trying to perform auto-indent using a FormattingModelBuilder in my custom language. However, it's indenting the way, I would want it to, and I can't figure how to get it right.
This is what I would like:
<indentTest> =
(
one | two
| three (
four five
)
| six
);
but this is what I get:
<indentTest> =
(
one | two
| three (
four five
)
| six
);
Note that it works as expected, if the first parenthesis of the group start on a new line:
<indentTest> =
(
one | two
| three
( <----
four five
)
| six
);
I have the Block structure arranged so that each word token or "|" symbol is a LeafBlock, and each "(...)" is a GroupBlock which has child which are each LeafBlocks or GroupBlocks. All the children of a GroupBlock have Indent: NORMAL except for the blocks for the parentheses characters themselves which have Indent: NONE.
I understand that this is because the indentation of a given block is relative to the closest ancestor Block which starts on a new line. In the above case, since the parent GroupBlock of "four" does not begin on a new line (it comes after "three" on the same line), the "four" block is indented relative to the outer GroupBlock which is aligned with the leftmost column.
How could I change my Block structure or Indentation assignment to make this work as I would like? I want the entire Group to be indented relative to the line on the which the Group starts. I've tried to get this to work with Alignment, but while I could finagle the closing ')' to align in the right place, that still doesn't help with the indentation of inner elements of the GroupBlocks.
Thank you!
Please sign in to leave a comment.
An indent is ignored if a corresponding block does not start with a new line. You can enforce the indent in this case using enforceIndentToChidlren parameter, for example: