Block indent always relative to top of file?!
I'm creating a Formatter for language that has basically two types, A and B, and looks like this:
A B
B
B
A B
...
Lines with A should start at the beginning of the line, lines without A should be indented.
My Psi tree starts at PsiFile where all children are a mixture of WHITE_SPACE, CRLF, A, and B. B has subchildren.
I've created blocks for A, B, and all children of B. My indent function for my blocks looks like this:
@Override
public Indent getIndent() {
if (this.getNode().getElementType() == B) {
return Indent.getSpaceIndent(4);
else
return Indent.getNoneIndent(); // applies to A and children of B
}
The problem is that the formatter will always indent all selected lines relative to the first line in the file, so indentation breaks if the file starts with a " B" line.
What is wrong here? This almost looks like a bug ...
Please sign in to leave a comment.
Hi Lars,
Are there any lines that contain A that don't start with A? If A always starts a line, you could try Indent.getAbsoluteNodeIndent() for block == A, which will position A in the leftmost column of the document.