rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 300 forks source link

SmartIndenter applies inconsistent indent, depending upon line number length #3193

Open ThunderFrame opened 7 years ago

ThunderFrame commented 7 years ago

Before indent:

Sub foo()
1 Dim x
10 Dim x
100 Dim x
1000 Dim x
10000 Dim x
100000 Dim x
End Sub

'After indent

Sub foo()
1   Dim x
10  Dim x
100 Dim x
1000 Dim x
10000 Dim x
100000 Dim x
End Sub

Arguably, the indentation should scan for the longest line number length, and then indent at a multiple of the standard-indent-size, like the following, where the line-number length forces indentation to 8 spaces (2x 4 spaces):

Sub foo()
1       Dim x
10      Dim x
100     Dim x
1000    Dim x
10000   Dim x
100000  Dim x
End Sub
retailcoder commented 7 years ago

Hmm, I think the indenter might still be ignoring/stripping line numbers.

retailcoder commented 7 years ago

The indentation actually is consistent, it's the line numbering that isn't. Typically in a line-numbered program you'll have consistent-width line numbers, like this:

Sub foo()
100000 Dim x
100001 Dim x
100010 Dim x
100100 Dim x
101000 Dim x
110000 Dim x
End Sub