chemoish / atom-valign

MIT License
5 stars 1 forks source link

Aligning on variable assignment #5

Closed Jaeiya closed 9 years ago

Jaeiya commented 9 years ago

This is a great plugin. I have only one suggestion

from

var myvar1 = sometext,
  myvar2 = sometextlonger,
  myvarlonger3 = somettext,
  myvar4 = moretext;

to

var myvar1       = sometext,
    myvar2       = sometextlonger,
    myvarlonger3 = somettext,
    myvar4       = moretext;
chemoish commented 9 years ago

Hi @Aedaeum,

Thanks for the feature request. This annoys me like no other, but I have been manually aligning it since I moved from coffee => javascript.

I will get on this as soon as I figure out whether or not I want to refactor this package to be more configurable.

Jaeiya commented 9 years ago

Thanks for the quick response. I will definitely be looking forward to this.

chemoish commented 9 years ago

Now that I am thinking about it, it is getting pretty complex.

I might start with something then we can tweak it. I wonder if my friend has tackled this problem yet.

1: var func = function () {};
2: # comment here
3: var one = 1,
4:     two = 2;
5: var secret = 'key';
6: var three = 3,
7:     four = 4;

Currently, the implementation for comments are ignored, but I forgot how exactly I implemented them. What if you try to align the comment? What if you try to align the first two var statements (It should skip over the comment, but not break because of it)?

If you align line 5, the implementation as it stands will grab line 6, but I am guessing line 7 would want to be captured. Does this also mean boundaries should be stepped by reaching to variables above it (Lines 1 - 4)?

My thought is that we start with finding the var and sticking to that block. My code style is that if you are separating out var statements (As in lines 3 and 6), there probably should be a new line between them.

Jaeiya commented 9 years ago

I agree that sticking to each var block separated by a new line is preferable.

chemoish commented 9 years ago

@Aedaeum, lots of breaking changes with all the code modifications. Though the basic feature support for var alignment is in there. It is a bit finicky because the implementation was even more complicated than I stated before.

Please let me know if you run into any other bugs caused by the refactor.

Fixed by 6ed73e85ac27f46ffe4d539102f5d6c4ee44ae4a