atom-alignment icon indicating copy to clipboard operation
atom-alignment copied to clipboard

Align current block when no selection

Open dwelle opened this issue 11 years ago • 2 comments

What adrianlee44/atom-vertical-align does. The gif from his repo sums it up:

img

dwelle avatar Dec 10 '14 22:12 dwelle

Very cool. What's the main difference between the two repos? This would be pretty simple to add, though it'd technically break backward-compatibility. Also, what do you consider a block? Is it lines of code with valid separators beside eachother or maybe better to be lines that are the same indentation with zero whitespace between?

blakeembrey avatar Dec 11 '14 01:12 blakeembrey

Sorry for late response. The main difference is that your repo works flawlessly even for multiple separators on the same line (except for edge cases) - kudos for that.

As for how to implement this, I haven't looked at the code of the other repo, so I can't really say. The other repo breaks block on comments (which are excluded from the alignment, since they can contain separators, too - and we wouldn't want to align those).

I'd go both with the same indent & valid separators. Also, not sure if to break on comments, because you can usually see this:

var x = 'asdasd',
    // comment explaning this var
    asda = 'asdasd,
    // comment explaning this var
    asdasd = 'asdasd';

So a better solution would be something like: 1) same indent 2) not separated by double \n 3) valid separators, unless a comment 4) exclude comments

Either way, this is not so important feature, and even if it is implement more naively (for example, break on comment as the other repo), it will suffice.

dwelle avatar Dec 13 '14 09:12 dwelle