Formatter alignment - unsure about tutorial explanation


I'm strugling with understanding tutorial for language plugin of Formatter's alignment/wrap.

I understand, that elements sharing the same alignment instance do align, what I don't understand is "and if the second block is the first non-whitespace block in its line".

var a = 1;
var aa = 1;

With simple example like this, how I should build blocks, since equal sign have to be aligned, but in order to have "=" as first non-whitespace block, I can't split given rows into multiple blocks - how should I set alignment for it?

The same goes for Wrapping - I assume that wrap should be specified in an expression so for example:

var a = "asd asd asd" + "asd asd asd" + "asd asd asd" + "asd asd asd"

Wrapping could be could be set on "+" sign, so it would result f.e.?

var a = "asd asd asd" + "asd asd asd"
+ "asd asd asd" + "asd asd asd"

Can it also be defined that Wrap happens always, once the whole expression is on 2 or more lines, instead of just after reaching right margin, so it would then result into something like this?

var a = "asd asd asd"
+ "asd asd asd"
+ "asd asd asd"
+ "asd asd asd"
1 comment
Comment actions Permalink

If I may, I'd like to extend the question, how does it fit with Spacing.
Do I understand correctly, that Aligment has to fit within it?

As example above, spacing around "=" sign should then be something like?

.spacing(1, Int.MAX_VALUE, ...)

And if there were max spaces something like:

.spacing(1, 3, ...)

Then it could result into something like:

var a  = "does not fit with last var"
var aa = "does not fit with last var"
var this_is_long = ""

Can't figure it out yet.


Please sign in to leave a comment.