atom-elastic-tabstops icon indicating copy to clipboard operation
atom-elastic-tabstops copied to clipboard

Should ignore indentation tabs

Open peoro opened this issue 5 years ago • 2 comments

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...

peoro avatar Apr 01 '19 22:04 peoro

@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.

hax avatar Apr 21 '19 14:04 hax

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...

  • we could have a flag to choose the "elastic tabstops style" (i.e. whether indentation tabs are excluded in the processing).
  • context-dependent tabs: if some tabs in two consecutive lines are followed by the same non-word character (\ in my example, / when aligning comments etc), they could be aligned together.

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

peoro avatar Apr 23 '19 15:04 peoro