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

Indenter adds stray As tokens in continued Dim lines. #2407

Closed comintern closed 7 years ago

comintern commented 7 years ago

Not sure how this one slipped by all the indenter tests, but this...

Sub MySub()
Dim x1 As Integer
Dim x2 As _
Integer
Dim x3 As Integer: _
Dim x4 As _
Integer
Dim x5 As Integer _
'Comment _
as _
integer
End Sub

...indents to this if align Dims is enabled:

Sub MySub()
    Dim x1    As Integer
    Dim x2    As _
    Integer   As 
    Dim x3    As Integer: _
    Dim x4    As _
    Integer   As 
    Dim x5    As Integer _
        'Comment _
        as _
        integer
End Sub

Note the extra As tokens after the lines with a bare Integer on them. This one's on me apparently, because while the VB6 Smart Indenter does this...

Sub MySub()
    Dim x1     As Integer
    Dim x2     As _
        Integer
    Dim x3     As Integer: _
            Dim x4 As _
                Integer
    Dim x5     As Integer _
                                                 'Comment _
                                                 as _
                                                 integer
End Sub

...at least it compiles afterwards.

comintern commented 7 years ago

This was actually a regression caused by 941196d it's now covered in tests.