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

Indentation stops at lines beginning with "Sub" #2470

Closed DougGlancy closed 7 years ago

DougGlancy commented 7 years ago

If a line in a procedure starts with the three characters "sub" then indenting of that procedure stops at that point. So this...

Sub Test()
If True Then
   i = 1
   Submariner = i 'or SubTotalsOn or Subpar or anything that starts with "Sub:
End If
End Sub

Yields this:

Sub Test()
If True Then
   i = 1
Submariner = i 'or SubTotalsOn or Subpar or anything that starts with Sub
End If
End Sub

I tested it in a Sub and a Function. I assume the parsing hits "Sub" and resets. I tried using a variable name that starts with "Function" and the indenting worked fine.

ThunderFrame commented 7 years ago

Indents fine for me using 2.0.10.33433.

Maybe it's fixed, or it depends on indenter settings?

Sub Test()
    If True Then
        i = 1
        Submariner = i                           'or SubTotalsOn or Subpar or anything that starts with "Sub:
    End If
End Sub
Vogel612 commented 7 years ago

FWIW this shouldn't be affected by the parser in any way. The parser works on complete tokens. the Sub token can only span a complete sub everything inside it is a different token.

DougGlancy commented 7 years ago

@Vogel612 , to be clear, I have no actual knowledge of how the indenting works. My bug reporting was just based on reducing some code to the simplest reproducible example. However, based on what you said about tokens, is it possible that the "Sub..." inside a procedure is seen as the start a new token? At any rate @ThunderFrame thinks this may be solved. I'm just going off of the release version 2.0.0.18871.

comintern commented 7 years ago

I can't replicate this with my settings either. Can you post your rubberduck.config file from \Users\You\AppData\Roaming\Rubberduck?

DougGlancy commented 7 years ago

@comintern, Here's two. One where I clicked the reset button, and one with a couple of changes: indent to 3, and Indent Entire Procedure Body unchecked. The behavior is the same in both cases.

rubberduck_dglancy_reset.txt rubberduck_dglancy_modified.txt

comintern commented 7 years ago

This was fixed in commit d7bbe58a.

DougGlancy commented 7 years ago

@comintern, okay, I'll close it then.