SublimeText / ElasticTabstops

Tab characters automatically adjust to keep adjacent lines aligned.
https://github.com/SublimeText/ElasticTabstops
67 stars 6 forks source link

Differentiate between "left" vs "right" tabstops #18

Open eugenesvk opened 3 years ago

eugenesvk commented 3 years ago

First of all, thanks a lot for creating this addon, I wish ST had a proper native support of elastic tabstops, but in the meantime your "lite" version is a great substitute!

However, there is one issue with elastic tabstops that appears when you use them both for "left-level" alignment (e.g. creating different levels from the beginning of a line) and for "right-level" alignment (e.g. for comments): if you have a comment on every line and if you want these comments vertically aligned with the help of your addon, it will break alignment of procedures at the start of the line like so (tabstops below are indicated with ):

→SomeVeryLongFunctionName(); →// 1 "left" tabstop and 1 "right" tabstop
→for (i                      →// same here, both vertical levels are aligned (left and right)
→{                           →// ISSUE: if you try to add a second tabstop to align the comments
→                            →if (...  // this line would BREAK: "if" is moved to the "right" alignment level with comments
→→if (... // instead of remaining at the second "left" level 
→→{

Currently the only way to resolve this is to mix tabs/spaces, e.g. use spaces for the "left" alignment and use tabstops for the "right" alignment and let your addon do it's magic ("left" alignment with spaces is usually easier since it's of constant width)

I was wondering if that's somehow possible to differentiate between the "left" and "right" tabstops at the level of your addon or is it too complicated? Thanks!

P.S. The differentiation of "left" and "right" tabstops might still lead to imperfections, e.g. this alignment would need additional rules to work since the first line has 1 "right" tabstop, while the second line technically only 1 "left" tabstop, though it should be also treated like a "right" tabstop

function(→arg1
         →arg2)

However, even without any extra logic to handle this, it'd still be an improvement over the current inability to align comments if you have different levels from the beginning of the line