better-align
better-align copied to clipboard
it breaks "===" in javascript string block
- I'm sorry that I find it breaks "===" in javascript string block
php
hope fix soon
I'm not sure if this is the proper solution, but I think it might work to solve the issues described above. I'm not entirely sure how to write atom extensions or even test this change below, but perhaps @WarWithinMe might be able to use this as a solution and we can get this fixed 😄
Basically we're adding a new else if
statement after https://github.com/WarWithinMe/better-align/blob/master/src/formatter.ts#L201 to check for the cases above.
let char = text.charAt(pos);
let next = text.charAt(pos+1);
let prev = pos > 0 ? text.charAt(pos-1) : "";
...
} else if ( char == "=" && next == "=" ) {
currTokenType = TokenType.Word;
nextSeek = 2;
} else if ( char == "=" && (prev == "=" || prev == "<" || prev == ">") ){
currTokenType = TokenType.Word;
nextSeek = 1;
}
...
For the case where ===
is encountered, it will first trigger the first if
above on when analyzing the first =
in the string and then push to the nextSeek to look at the third =
which then gets marked as an TokenType.Assignment
a few else if
statements later. But if we check check to see if the previous character is =
we'll mark it as a TokenType.Word
and not reach the later else if
statement.
For the case of <=
and >=
, the last logic applies. It reaches our new if
and marks it as a Word
before it gets a chance to reach the assignment check.
I created a pull-request to fix this #41 . Please @WarWithinMe check and accept it, thanks!
Please, update your plagin for VS Сode with this fix. Thanks lot!