Just for reference, I'm using atom-alignment version 0.12.1, where the default configuration appears to be:
- Align By:
[ '=>', ':=', ':', '=' ]
- Alignment Space Chars: [ '=>', ':=', '=' ]
(By the way, can someone explain to me why :
is left out of "Alignment Space Chars"? Is that intentional? What purpose does it serve?)
When I select the following lines and invoke "Align":
aaa = 1
aaaa = 1
bbb: 2
bbbb: 2
ccc : 3
cccc : 3
ddd=>4
ddd=>4
eee => 5
eee => 5
fff := 6
ffff := 6
I get the following:
aaa = 1
aaaa = 1
bbb: 2
bbbb: 2
ccc : 3
cccc : 3
ddd =>4
ddd =>4
eee => 5
eee => 5
fff : = 6
ffff : = 6
Note that in particular the =
and =>
lines seem to have been properly aligned (or at least aligned as I expected) but that the :
character seems to have been ignored, and :=
has actually been split at the =
.
If I move the bbb
(colon) lines above the aaa
(equals) lines, like this:
bbb: 2
bbbb: 2
aaa = 1
aaaa = 1
ccc : 3
cccc : 3
ddd=>4
ddd=>4
eee => 5
eee => 5
fff := 6
ffff := 6
and invoke align, now I get this:
bbb : 2
bbbb : 2
aaa = 1
aaaa = 1
ccc : 3
cccc : 3
ddd=>4
ddd=>4
eee => 5
eee => 5
fff := 6
ffff := 6
Here the :
and :=
patterns have been aligned and the =
and =>
lines have been ignored.
If I understand this correctly, it looks like atom-alignment looks for the first line in the selection that contains one of the Align By patterns, and then aligns the remaining lines in the selection based on that pattern. Hence, as seen in the example above, it matters whether :
or =
appears first in the selection.
What I expected is (1) consistent behavior given the same set of lines (regardless of the order in which they appear and (2) to align by the first occurrence of any character sequence in the Align By list in each line (where the order of elements in the Align By list determines which sequence to use when more than one Align By sequence is found in the line.)
In other words, I expected this alignment:
aaa = 1
aaaa = 1
bbb : 2
bbbb : 2
ccc : 3
cccc : 3
ddd =>4
ddd =>4
eee => 5
eee => 5
fff := 6
ffff := 6
To be honest it isn't clear to me whether or not the behavior I reported above is the expected behavior, but the align-by-any logic that leads to my final listing seems to me to be both a more intuitive result but also an objectively better result, in that it doesn't break operators like =>
, ?=
, +=
, etc. during the alignment. (Even worse, the current behavior is to sometimes break those operators depending upon which lines are selected and/or the order in which the lines are found.)
Is there any way to accomplish the alignment found in my final listing?