hax / atom-elastic-tabstops

Elastic Tabstops for Atom
MIT License
84 stars 1 forks source link

Should ignore indentation tabs #29

Open peoro opened 5 years ago

peoro commented 5 years ago

Currently all tabs (indentation tabs + other tabs) are treated the same way to align code.

This means that the following piece of code:

if( hey ) {\t// ...
\tHello! Uh,\t// ...
\toh :(\t// ...
}\t// ...

Will result in:

if( hey ) {  // ...
             Hello! Uh,  // ...
             oh :(       // ...
}            // ...

While I believe that it should result in:

if( hey ) {     // ...
    Hello! Uh,  // ...
    oh :(       // ...
}               // ...

Indentation tabs (all tabs coming before the first non-tab character in a line) should be ignored by the elastic tabstop logic.

I'm finding it especially annoying for stuff like trailing backslashes: I'd like to align all of them together using elastic tabstops, but if some lines are indented it doesn't quite work...

hax commented 5 years ago

@peoro

There are important cases which rely on current behavior:

const  x = 1,
       y = 2,
       z = 3;
csv sample

head1  head2  head3
apple  boy    cat
egg           fly    (the second column is empty)
       girl   hand   (the first column is empty)

As I understand, the original idea of elastic tabstops is unification of indentation and alignment. Or, strictly speaking, it makes indentation as a special case of alignment. But in your cases, you want to differentiate the "pure indentation" and the alignment. I'm still thinking about this issue, whether it possible and how to deal with different use cases.

peoro commented 5 years ago

Hey @hax, thanks for considering this issue.

I didn't think about the use cases you brought up. The original documentation of elastic tabstops seems to describe the behavior this package implements, so with this issue I'm asking for a non-standard, incompatible behavior, oops.

I can think of a few ways to make this package compatible with my programming style, but all of them have some big downsides and go against the elastic tabstops standard...

I should probably try to discuss styles and solutions upstream though...